Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] [Impeller] master branch: Virtual display platformview is broken on Android 10 (api 29) or lower. #160480

Closed
timbotimbo opened this issue Dec 17, 2024 · 4 comments · Fixed by #160634
Labels
e: impeller Impeller rendering backend issues and features requests e: opengl team-engine Owned by Engine team

Comments

@timbotimbo
Copy link

timbotimbo commented Dec 17, 2024

Description

My Virtual Display test project (used in other issues) is broken on the current master branch with Impeller enabled on Android.

It is using a Surfaceview and falls back to the Virtual Display platform view mode.
The platformview shows up as some kind of black gradient instead of an image.

Disabling impeller prevents the issue.
Using a Flutter stable up to 3.27 prevents the issue.

Expected result

Show an image of some mountains with both Impeller enabled and disabled.

Actual result

The image shows up as a weird gradient when using Impeller after the breaking commit.

Screenshots

Impeller disabled vs Impeller enabled, using the config from Flutter doctor below.
The '+' buttons has been pressed to make the image full size.

Tested configurations

Flutter versions

Tested Flutter versions

  • 3.22.3 ✓ (impeller manually enabled)
  • 3.24.5 ✓ (impeller manually enabled)
  • 3.27.0 ✓
  • 3.27.1 ✓
  • 3.28.0-0.1.pre ❌ broken
  • master (3.28.0-1.0.pre.160) ❌ broken

Devices

Work as expected:

  • Samsung Galaxy S20FE 4G Android 13 (Api 33) ✓
  • Pixel 4 API 33 emulator ✓
  • Nokia 8.1 Android 11 (API 30) ✓

Broken:

  • Pixel 8 API 29 emulator ❌
  • Samsung Galaxy S8 Android 9 (Api 28) ❌
  • Pixel 4 API 26 emulator ❌
  • Pixel 6 api 24 emulator ❌

In case it is needed the S8 has:
CPU: Exynos 8895
GPU: Mali-G71 MP20

Breaking commit

I tracked the change to the following commit:
1ef8d51

Using master just 1 commit earlier doesn't show any issues, while using this commit breaks my code sample.

There are plenty Impeller revisions in the 47 included in this engine roll, so I'm not sure which change to blame exactly.

Code sample

Use the following repo project
https://github.com/timbotimbo/flutter-GLTest/tree/initial-3.24.5

The example basically boils down to a platformview in a green container.

Scaffold(
 body: Container(
        color: Colors.green,
        child: const AndroidView(
          viewType: "SurfaceView",
          layoutDirection: TextDirection.ltr,
          creationParamsCodec: StandardMessageCodec(),
          hitTestBehavior: PlatformViewHitTestBehavior.transparent, 
        )
    );
);

Reproduction

To reproduce the issue:

  1. Just run the code sample on an Android device or emulator.
    • Only Android <= 10 will show the issue.
  2. Optionally press the '+' button to resize and refresh the platformview.
  3. Check if you see an image rendered on top of the green container.
    • Flutter versions past the mentioned commit (like the first 3.28 beta) show a black transparent gradient.

Logs

Log at breaking commit (Galaxy S8, Android 9)
Launching lib\main.dart on SM G950F in debug mode...
√ Built build\app\outputs\flutter-apk\app-debug.apk
I/flutter ( 9247): [IMPORTANT:flutter/shell/platform/android/android_context_gl_impeller.cc(79)] Using the Impeller rendering backend (OpenGLES).
Connecting to VM Service at ws://127.0.0.1:1049/nAK3rB99Fpc=/ws
Connected to the VM Service.
D/vndksupport( 9247): Loading /vendor/lib64/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.
I/Choreographer( 9247): Skipped 168 frames!  The application may be doing too much work on its main thread.
I/PlatformViewsController( 9247): Hosting view in a virtual display for platform view: 0
I/PlatformViewsController( 9247): PlatformView is using SurfaceTexture backend
D/Dialog  ( 9247): mIsSamsungBasicInteraction = false
D/Dialog  ( 9247): mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
I/DecorView( 9247): createDecorCaptionView >> DecorView@a5d2d60[], isFloating: false, isApplication: false, hasWindowDecorCaption: false, hasWindowControllerCallback: false
D/InputTransport( 9247): Input channel constructed: fd=93
D/ViewRootImpl@fabdeea[MainActivity]( 9247): setView = DecorView@a5d2d60[MainActivity] TM=true MM=false
D/ViewRootImpl@ccac364[MainActivity]( 9247): Relayout returned: old=[0,0][720,1480] new=[0,0][720,1480] result=0x3 surface={valid=true 516787380224} changed=false
V/InputMethodManager( 9247): Not IME target window, ignoring
D/SurfaceView( 9247): onWindowVisibilityChanged(0) true android.view.SurfaceView{9874878 V.E...... ......ID 0,0-0,0} of ViewRootImpl@fabdeea[MainActivity]
D/ViewRootImpl@fabdeea[MainActivity]( 9247): dispatchAttachedToWindow
D/ViewRootImpl@fabdeea[MainActivity]( 9247): Relayout returned: old=[0,0][360,692] new=[0,0][360,692] result=0x7 surface={valid=true 516157325312} changed=true
D/mali_winsys( 9247): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/OpenGLRenderer( 9247): eglCreateWindowSurface = 0x783a8f9600, 0x782d5fc010
D/SurfaceView( 9247): show() Surface(name=SurfaceView - Sys2030:com.example.myGLView.gltest/com.example.myGLView.gltest.MainActivity@9874878@0[9247])/@0xb7e9b51 android.view.SurfaceView{9874878 V.E...... ......ID 0,0-360,692}
D/SurfaceView( 9247): surfaceCreated 0 #8 android.view.SurfaceView{9874878 V.E...... ......ID 0,0-360,692}
D/SurfaceView( 9247): surfaceChanged (360,692) 0 #8 android.view.SurfaceView{9874878 V.E...... ......ID 0,0-360,692}
D/ViewRootImpl@fabdeea[MainActivity]( 9247): Relayout returned: old=[0,0][360,692] new=[0,0][360,692] result=0x3 surface={valid=true 516157325312} changed=false
D/ViewRootImpl@fabdeea[MainActivity]( 9247): MSG_RESIZED: frame=Rect(0, 0 - 360, 692) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
D/ProfileInstaller( 9247): Installing profile for com.example.myGLView.gltest
Log of last working commit (Galaxy S8, Android 9)
Launching lib\main.dart on SM G950F in debug mode...
√ Built build\app\outputs\flutter-apk\app-debug.apk
Connecting to VM Service at ws://127.0.0.1:1419/NGwHrlHiNs4=/ws
Connected to the VM Service.
D/vndksupport( 9905): Loading /vendor/lib64/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.
I/Choreographer( 9905): Skipped 174 frames!  The application may be doing too much work on its main thread.
I/PlatformViewsController( 9905): Hosting view in a virtual display for platform view: 0
I/PlatformViewsController( 9905): PlatformView is using SurfaceTexture backend
D/Dialog  ( 9905): mIsSamsungBasicInteraction = false
D/Dialog  ( 9905): mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
I/DecorView( 9905): createDecorCaptionView >> DecorView@a5d2d60[], isFloating: false, isApplication: false, hasWindowDecorCaption: false, hasWindowControllerCallback: false
D/InputTransport( 9905): Input channel constructed: fd=93
D/ViewRootImpl@fabdeea[MainActivity]( 9905): setView = DecorView@a5d2d60[MainActivity] TM=true MM=false
D/ViewRootImpl@ccac364[MainActivity]( 9905): Relayout returned: old=[0,0][720,1480] new=[0,0][720,1480] result=0x3 surface={valid=true 516787380224} changed=false
V/InputMethodManager( 9905): Not IME target window, ignoring
D/SurfaceView( 9905): onWindowVisibilityChanged(0) true android.view.SurfaceView{9874878 V.E...... ......ID 0,0-0,0} of ViewRootImpl@fabdeea[MainActivity]
D/ViewRootImpl@fabdeea[MainActivity]( 9905): dispatchAttachedToWindow
D/ViewRootImpl@fabdeea[MainActivity]( 9905): Relayout returned: old=[0,0][360,692] new=[0,0][360,692] result=0x7 surface={valid=true 515991863296} changed=true
D/mali_winsys( 9905): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/OpenGLRenderer( 9905): eglCreateWindowSurface = 0x7831bf8180, 0x7823830010
D/SurfaceView( 9905): show() Surface(name=SurfaceView - Sys2030:com.example.myGLView.gltest/com.example.myGLView.gltest.MainActivity@9874878@0[9905])/@0xb7e9b51 android.view.SurfaceView{9874878 V.E...... ......ID 0,0-360,692}
D/SurfaceView( 9905): surfaceCreated 0 #8 android.view.SurfaceView{9874878 V.E...... ......ID 0,0-360,692}
D/SurfaceView( 9905): surfaceChanged (360,692) 0 #8 android.view.SurfaceView{9874878 V.E...... ......ID 0,0-360,692}
D/ViewRootImpl@fabdeea[MainActivity]( 9905): Relayout returned: old=[0,0][360,692] new=[0,0][360,692] result=0x3 surface={valid=true 515991863296} changed=false
D/ViewRootImpl@fabdeea[MainActivity]( 9905): MSG_RESIZED: frame=Rect(0, 0 - 360, 692) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
D/ProfileInstaller( 9905): Installing profile for com.example.myGLView.gltest

Flutter doctor

Flutter doctor With FLutter master at the exact commit that breaks things and the Galaxy S8 connected.
[√] Flutter (Channel master, 3.27.0-1.0.pre.525, on Microsoft Windows [Version 10.0.19045.5247], locale en-GB)
    • Flutter version 3.27.0-1.0.pre.525 on channel master at C:\Flutter\flutter_windows_default\flutter      
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 1ef8d51282 (5 weeks ago), 2024-11-15 21:02:25 -0500
    • Engine revision f649330aff
    • Dart version 3.7.0 (build 3.7.0-153.0.dev)
    • DevTools version 2.41.0-dev.2

[√] Windows Version (10 Pro 64-bit, 22H2, 2009)

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\XXXXX\AppData\Local\Android\sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java      
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11609105)      
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.3) 
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community  
    • Visual Studio Community 2022 version 17.12.35527.113
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.10+0--11609105)

[√] VS Code (version 1.96.0)
    • VS Code at C:\Users\XXXXX\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.102.0

[√] Connected device (4 available)
    • SM G950F (mobile) • ce051715c588912a01 • android-arm64  • Android 9 (API 28)
    • Windows (desktop) • windows            • windows-x64    • Microsoft Windows [Version 10.0.19045.5247]
    • Chrome (web)      • chrome             • web-javascript • Google Chrome 131.0.6778.109
    • Edge (web)        • edge               • web-javascript • Microsoft Edge 131.0.2903.99

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

• No issues found!
@timbotimbo timbotimbo changed the title [Android] [Impeller] master branch: Virtual display platformview is broken on Android 10 (api 29) or older. [Android] [Impeller] master branch: Virtual display platformview is broken on Android 10 (api 29) or lower. Dec 17, 2024
@jonahwilliams jonahwilliams added e: impeller Impeller rendering backend issues and features requests team-engine Owned by Engine team labels Dec 17, 2024
@jonahwilliams
Copy link
Member

I suspect this broke due to flutter/engine#56591 , which enabled Impeller OpenGLES as a fallback for non-Vulkan devices.

@jonahwilliams
Copy link
Member

Its likely that the devices that aren't working correctly were not using Impeller before that patch.

@jonahwilliams
Copy link
Member

I can reproduce this as long as two conditions are met.

  1. Impeller OpenGLES backend
  2. SurfaceTexture backend (not surface producer).

@matanlurey
Copy link
Contributor

I can reproduce this as long as two conditions are met.

  1. Impeller OpenGLES backend
  2. SurfaceTexture backend (not surface producer).

Just for clarity, SurfaceProducer conditionally uses Surface texture <29.

@camsim99 was seeing some issues with Camera Preview.

github-merge-queue bot pushed a commit that referenced this issue Dec 20, 2024
Fixes #160480

Both The Impeller and Skia variant of the OES texture rendering use the
same shared code path, so the Impeller code must match the weird 1x1
texture behavior of Skia. In addition, we have to add back the
TiledTextureContents support, since we need to render a texture with a
transform. I had previously tested this but neglected to force the
SurfaceTexture path, so I only tested the ImageReader path which does
not use a transform.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e: impeller Impeller rendering backend issues and features requests e: opengl team-engine Owned by Engine team
Projects
None yet
3 participants