Skip to content

TLHC platform views on Android 14/15 stop updating on resume #146499

@evil159

Description

@evil159

Steps to reproduce

I've created a new project with flutter create and integrated a simple test view on Android side as per https://docs.flutter.dev/platform-integration/android/platform-views.
Set up FlutterEngine cache as per Step 3 of this guide https://docs.flutter.dev/add-to-app/android/add-flutter-screen#step-3-optional-use-a-cached-flutterengine.

Steps to reproduce
  1. Launch the app
  2. Switch to Home Screen
  3. Open an app or two(camera, phone app etc.)
    • This step can be skipped if Developer option > Don't keep activities is enabled
  4. Go back to the sample app.
Environment
  • Pixel 8 running AP31.240223.016.A3(Android 15 Preview)

Sample project: platform_view_test 3.zip

Expected results

The platform view hosted by Flutter app is displayed and interactive.

Actual results

  • On Galaxy the platform view is not displayed, instead the place it used to occupy is rendered solid white.
  • On Pixel the platform view is displayed, but not interacting(doesn't respond to touch).

Code sample

Code sample

Dart:

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
      final Map<String, dynamic> creationParams = <String, dynamic>{};

    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text("App"),
      ),
      body: AndroidView(
        viewType: "nativeView",
        layoutDirection: TextDirection.ltr,
        creationParams: creationParams,
        creationParamsCodec: const StandardMessageCodec(),
      ),
    );
  }
}

Platform side:

class MyApplication : Application() {
    private lateinit var flutterEngine : FlutterEngine

    override fun onCreate() {
        super.onCreate()

        // Instantiate a FlutterEngine.
        flutterEngine = FlutterEngine(this)

        // Start executing Dart code to pre-warm the FlutterEngine.
        flutterEngine.dartExecutor.executeDartEntrypoint(
            DartExecutor.DartEntrypoint.createDefault()
        )

        // Cache the FlutterEngine to be used by FlutterActivity.
        FlutterEngineCache
            .getInstance()
            .put("my_engine_id", flutterEngine)
    }
}

class RootActivity: Activity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        startActivity(
            FlutterActivity.CachedEngineIntentBuilder(MainActivity::class.java, "my_engine_id")
                .build(this)
        )
        finish()
    }
}

class MainActivity: FlutterActivity() {
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        flutterEngine
            .platformViewsController
            .registry
            .registerViewFactory("nativeView", NativeViewFactory())
    }
}

Screenshots or Video

Screenshots / Video demonstration
Screen_recording_20240409_135855.mp4

Logs

Logs
---------------------------- PROCESS STARTED (19824) for package com.example.platform_view_test ----------------------------
2024-04-09 14:01:09.947 19824-19824 Compatibil...geReporter com.example.platform_view_test       D  Compat change id reported: 171979766; UID 10274; state: ENABLED
2024-04-09 14:01:09.947 19824-19824 Compatibil...geReporter com.example.platform_view_test       D  Compat change id reported: 242716250; UID 10274; state: DISABLED
2024-04-09 14:01:09.959 19824-19824 ApplicationLoaders      com.example.platform_view_test       D  Returning zygote-cached class loader: /system_ext/framework/androidx.window.extensions.jar
2024-04-09 14:01:09.959 19824-19824 ApplicationLoaders      com.example.platform_view_test       D  Returning zygote-cached class loader: /system_ext/framework/androidx.window.sidecar.jar
2024-04-09 14:01:09.962 19824-19824 ziparchive              com.example.platform_view_test       W  Unable to open '/data/data/com.example.platform_view_test/code_cache/.overlay/base.apk/classes.dm': No such file or directory
2024-04-09 14:01:09.975 19824-19824 ziparchive              com.example.platform_view_test       W  Unable to open '/data/app/~~Jwigw4BUI7MoNTTzWd31uw==/com.example.platform_view_test-mcIrPFuHK3VSxqnVEsDqsg==/base.dm': No such file or directory
2024-04-09 14:01:09.975 19824-19824 ziparchive              com.example.platform_view_test       W  Unable to open '/data/app/~~Jwigw4BUI7MoNTTzWd31uw==/com.example.platform_view_test-mcIrPFuHK3VSxqnVEsDqsg==/base.dm': No such file or directory
2024-04-09 14:01:10.011 19824-19824 nativeloader            com.example.platform_view_test       D  Configuring clns-6 for other apk /data/app/~~Jwigw4BUI7MoNTTzWd31uw==/com.example.platform_view_test-mcIrPFuHK3VSxqnVEsDqsg==/base.apk. target_sdk_version=33, uses_libraries=, library_path=/data/app/~~Jwigw4BUI7MoNTTzWd31uw==/com.example.platform_view_test-mcIrPFuHK3VSxqnVEsDqsg==/lib/arm64:/data/app/~~Jwigw4BUI7MoNTTzWd31uw==/com.example.platform_view_test-mcIrPFuHK3VSxqnVEsDqsg==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.example.platform_view_test
2024-04-09 14:01:10.024 19824-19824 GraphicsEnvironment     com.example.platform_view_test       V  Currently set values for:
2024-04-09 14:01:10.024 19824-19824 GraphicsEnvironment     com.example.platform_view_test       V    angle_gl_driver_selection_pkgs=[com.android.angle, com.linecorp.b612.android, com.campmobile.snow, com.google.android.apps.tachyon]
2024-04-09 14:01:10.024 19824-19824 GraphicsEnvironment     com.example.platform_view_test       V    angle_gl_driver_selection_values=[angle, native, native, native]
2024-04-09 14:01:10.024 19824-19824 GraphicsEnvironment     com.example.platform_view_test       V  com.example.platform_view_test is not listed in per-application setting
2024-04-09 14:01:10.025 19824-19824 GraphicsEnvironment     com.example.platform_view_test       V  Neither updatable production driver nor prerelease driver is supported.
2024-04-09 14:01:10.049 19824-19897 ResourceExtractor       com.example.platform_view_test       I  Found extracted resources res_timestamp-1-1712655907628
2024-04-09 14:01:10.052 19824-19896 nativeloader            com.example.platform_view_test       D  Load /data/app/~~Jwigw4BUI7MoNTTzWd31uw==/com.example.platform_view_test-mcIrPFuHK3VSxqnVEsDqsg==/lib/arm64/libflutter.so using ns clns-6 from class loader (caller=<unknown>): ok
2024-04-09 14:01:10.059 19824-19824 tform_view_test         com.example.platform_view_test       W  type=1400 audit(0.0:18469): avc:  denied  { read } for  name="max_map_count" dev="proc" ino=6767069 scontext=u:r:untrusted_app_32:s0:c18,c257,c512,c768 tcontext=u:object_r:proc_max_map_count:s0 tclass=file permissive=0 app=com.example.platform_view_test
2024-04-09 14:01:10.133 19824-20001 vulkan                  com.example.platform_view_test       D  searching for layers in '/data/app/~~Jwigw4BUI7MoNTTzWd31uw==/com.example.platform_view_test-mcIrPFuHK3VSxqnVEsDqsg==/lib/arm64'
2024-04-09 14:01:10.142 19824-19941 flutter                 com.example.platform_view_test       I  The Dart VM service is listening on http://127.0.0.1:40127/VYwrTLx62Uk=/
2024-04-09 14:01:10.160 19824-19824 Compatibil...geReporter com.example.platform_view_test       D  Compat change id reported: 279646685; UID 10274; state: DISABLED
2024-04-09 14:01:10.191 19824-20001 vulkan                  com.example.platform_view_test       D  added global layer 'VK_LAYER_KHRONOS_validation' from library '/data/app/~~Jwigw4BUI7MoNTTzWd31uw==/com.example.platform_view_test-mcIrPFuHK3VSxqnVEsDqsg==/lib/arm64/libVkLayer_khronos_validation.so'
2024-04-09 14:01:10.216 19824-20001 vulkan                  com.example.platform_view_test       D  searching for layers in '/data/app/~~Jwigw4BUI7MoNTTzWd31uw==/com.example.platform_view_test-mcIrPFuHK3VSxqnVEsDqsg==/base.apk!/lib/arm64-v8a'
2024-04-09 14:01:10.228 19824-19824 tform_view_test         com.example.platform_view_test       W  Accessing hidden method Landroid/view/accessibility/AccessibilityNodeInfo;->getSourceNodeId()J (unsupported,test-api, reflection, allowed)
2024-04-09 14:01:10.228 19824-19824 tform_view_test         com.example.platform_view_test       W  Accessing hidden method Landroid/view/accessibility/AccessibilityRecord;->getSourceNodeId()J (unsupported, reflection, allowed)
2024-04-09 14:01:10.228 19824-19824 tform_view_test         com.example.platform_view_test       W  Accessing hidden field Landroid/view/accessibility/AccessibilityNodeInfo;->mChildNodeIds:Landroid/util/LongArray; (unsupported, reflection, allowed)
2024-04-09 14:01:10.228 19824-19824 tform_view_test         com.example.platform_view_test       W  Accessing hidden method Landroid/util/LongArray;->get(I)J (unsupported, reflection, allowed)
2024-04-09 14:01:10.247 19824-19824 ContentCaptureHelper    com.example.platform_view_test       I  Setting logging level to OFF
2024-04-09 14:01:10.254 19824-19824 Compatibil...geReporter com.example.platform_view_test       D  Compat change id reported: 237531167; UID 10274; state: DISABLED
2024-04-09 14:01:10.301 19824-19824 WindowExtensionsImpl    com.example.platform_view_test       I  Initializing Window Extensions.
2024-04-09 14:01:10.581 19824-19855 tform_view_test         com.example.platform_view_test       I  Compiler allocated 4683KB to compile void android.view.ViewRootImpl.performTraversals()
2024-04-09 14:01:10.664 19824-19824 Compatibil...geReporter com.example.platform_view_test       D  Compat change id reported: 171228096; UID 10274; state: ENABLED
2024-04-09 14:01:10.666 19824-19824 Compatibil...geReporter com.example.platform_view_test       D  Compat change id reported: 210923482; UID 10274; state: ENABLED
2024-04-09 14:01:10.666 19824-19824 Compatibil...geReporter com.example.platform_view_test       D  Compat change id reported: 63938206; UID 10274; state: DISABLED
2024-04-09 14:01:10.703 19824-19855 tform_view_test         com.example.platform_view_test       I  Compiler allocated 4213KB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
2024-04-09 14:01:10.705 19824-19824 PlatformViewsController com.example.platform_view_test       I  Hosting view in view hierarchy for platform view: 0
2024-04-09 14:01:10.706 19824-19824 PlatformViewsController com.example.platform_view_test       I  PlatformView is using ImageReader backend
2024-04-09 14:01:10.706 19824-19824 Compatibil...geReporter com.example.platform_view_test       D  Compat change id reported: 236825255; UID 10274; state: DISABLED
2024-04-09 14:01:10.770 19824-19824 ImageTextu...istryEntry com.example.platform_view_test       E  Dropping PlatformView Frame
2024-04-09 14:01:10.777 19824-19824 ContentCaptureHelper    com.example.platform_view_test       I  Setting logging level to OFF
2024-04-09 14:01:11.933 19824-19824 ImageTextu...istryEntry com.example.platform_view_test       E  Dropping PlatformView Frame
2024-04-09 14:01:14.605 19824-19824 VRI[MainActivity]       com.example.platform_view_test       D  visibilityChanged oldVisibility=true newVisibility=false
2024-04-09 14:01:14.677 19824-19824 WindowOnBackDispatcher  com.example.platform_view_test       W  sendCancelIfRunning: isInProgress=falsecallback=android.view.ViewRootImpl$$ExternalSyntheticLambda11@e05917c
2024-04-09 14:01:17.388 19824-19824 ContentCaptureHelper    com.example.platform_view_test       I  Setting logging level to OFF
2024-04-09 14:01:18.676 19824-19824 Compatibil...geReporter com.example.platform_view_test       D  Compat change id reported: 289878283; UID 10274; state: DISABLED
---------------------------- PROCESS ENDED (19824) for package com.example.platform_view_test ----------------------------

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale en-FI)
    • Flutter version 3.19.5 on channel stable at /Users/romanlaitarenko/Downloads/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (12 days ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/romanlaitarenko//Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/romanlaitarenko//Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.87.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.86.0

[✓] Connected device (6 available)
    • Pixel 8 (mobile)            • 37280DLJH000VR                       • android-arm64  • Android 14 (API 34)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 14 (API 34) (emulator)
    • Roman’s iPhone (2) (mobile) • 00008110-00110D1614F9801E            • ios            • iOS 17.4.1 21E236
    • iPhone 15 Pro (mobile)      • AB1C69B3-AE98-458C-BD91-BEFAFF2357B0 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 123.0.6312.59

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: platform-viewsEmbedding Android/iOS views in Flutter appse: OS-version specificAffects only some versions of the relevant operating systemengineflutter/engine related. See also e: labels.found in release: 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions