Skip to content

[Android]The Hybrid composition Platform view will show on the top of page while resume the app from background. #89558

@neoyxm

Description

@neoyxm

Hi ,

We are developping an video app using Hybrid composition Platform view on android.

And here , we encounted an issue:

  1. render the video with Native view on main.dart
  2. open another flutter page to cover the video view
  3. press the Home button and put the app to background
  4. resume the app from Task list
  5. you will see the video view on the top of second page.

I simplified this issue to below sample code . This sample creates an surfaceview on the native side, and it will fill the entire canvas to RED while the surface create.

Every time put the app to background, the surfaceview will be destroyed. On resuming app to foreground,the surface view will be created again on the top of second page.

I have verified this issue on flutter channel master/dev/beta, and it can be reproduced on these channels.

BTW: Virtual Display mode does not have such issue. You could unmark the line 86 in mart.dart to verify that.

Dart side:
main.dart: https://github.com/neoyxm/neoMP/blob/master/main.dart
page2.dart: https://github.com/neoyxm/neoMP/blob/master/page2.dart

Native side to create the native view:
MainActivity.java: https://github.com/neoyxm/neoMP/blob/master/MainActivity.java
NativeView.java: https://github.com/neoyxm/neoMP/blob/master/NativeView.java
NativeViewFactory.java: https://github.com/neoyxm/neoMP/blob/master/NativeViewFactory.java

flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.1 20G80 darwin-x64, locale zh-Hans-CN)
    • Flutter version 2.2.3 at /opt/flutter
    • Framework revision f4abaa0735 (7 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/yangxm/Library/Android/sdk/
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/yangxm/Library/Android/sdk/
    • Java binary at: /Library/Java/JavaVirtualMachines/openjdk8/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_275-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.1

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

[!] Android Studio (version 2020.3)
    • 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
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

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

[✓] Connected device (3 available)
    • Pixel 3 (mobile) • 8ABX0PZMP • android-arm64  • Android 11 (API 30)
    • macOS (desktop)  • macos     • darwin-x64     • macOS 11.5.1 20G80 darwin-x64
    • Chrome (web)     • chrome    • web-javascript • Google Chrome 92.0.4515.159

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: platform-viewsEmbedding Android/iOS views in Flutter appsengineflutter/engine related. See also e: labels.found in release: 2.2Found to occur in 2.2found in release: 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions