-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
After a screen rotation, an Android platform view will sometimes show the results of a previous onDraw call instead of the most recent onDraw.
To reproduce:
- Patch the
native_driver_testAndroid integration test app to render a different color for portrait versus landscape mode- In https://github.com/flutter/flutter/blob/master/dev/integration_tests/native_driver_test/android/app/src/main/kotlin/com/example/native_driver_test/fixtures/BlueOrangeGradientPlatformViewFactory.kt, modify
onSizeChangedand replaceColor.rgb(0x41, 0x69, 0xE1)withif (w > h) Color.rgb(0x41, 0x69, 0xE1) else Color.rgb(0xFF, 0x00, 0x00)
- In https://github.com/flutter/flutter/blob/master/dev/integration_tests/native_driver_test/android/app/src/main/kotlin/com/example/native_driver_test/fixtures/BlueOrangeGradientPlatformViewFactory.kt, modify
Then run the app with:
- cd
dev/integration_tests/native_driver_test flutter run -t lib/platform_view_blue_orange_gradient_main.dart
This app instantiates a platform view that fills the view's canvas with a LinearGradient shader. The parameters of the shader are updated after a screen rotation or other size change.
With this patch, the app should show a red gradient in portrait mode and a blue gradient in landscape mode. But if I rotate the app many times on some devices, then the screen will sometimes render the red gradient after a rotation into landscape mode.
I've been able to reproduce this on a Pixel 6a (API level 32) and an Android API 33 emulator.
The platform_view_blue_orange_gradient_portrait_post_rotation Skia Gold test uses this app. That test has had some flakes where the screenshot looks like it rendered landscape content when the test expected portrait.