Android_hardware_smoke_test: Cache flutter engine when running vulkan backend instrumented tests#189026
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces caching and reuse of the FlutterEngine for the Vulkan backend in MainActivity to prevent teardown crashes and speed up test execution, along with corresponding cleanup in FlutterActivityTest. Feedback on these changes highlights potential memory leaks: a static reference to FlutterEngine should be wrapped in a WeakReference, and the MethodCallHandler registered on the cached engine should be cleared in cleanUpFlutterEngine to avoid capturing destroyed activity instances. Additionally, a more idiomatic Kotlin implementation is suggested for the engine caching logic.
- use a weak reference for the engine - clean up engine and method channel handlers - kotlin idioms
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements caching for the FlutterEngine on the Vulkan backend in MainActivity to avoid teardown crashes, along with associated cleanup in FlutterActivityTest and checks to prevent duplicate view factory registration. The review feedback identifies a potential memory leak in MainActivity.kt caused by passing an Activity context to the globally cached FlutterEngine, and suggests using the application context instead.
There was a problem hiding this comment.
Code Review
This pull request introduces engine caching for the Vulkan backend in the Android hardware smoke test to improve performance and prevent teardown crashes. It adds a tearDownClass method to the test suite and updates MainActivity to manage engine lifecycle, including tracking the last configured engine and cleaning up method channel handlers. Feedback was provided regarding the potential for memory leaks when reusing the NativeTextViewFactory and the incorrect approach to clearing method channel handlers in cleanUpFlutterEngine.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces caching of the FlutterEngine for the Vulkan backend in MainActivity to prevent teardown crashes and speed up test execution, along with corresponding cleanup in FlutterActivityTest. The review feedback recommends tracking the active activity instance via a static reference to prevent a race condition during activity transitions, which could otherwise cause a destroying activity to prematurely clear the method call handlers of a newly created activity on the shared cached engine.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements Flutter engine caching for the Vulkan backend in the Android hardware smoke test to prevent teardown crashes and optimize test execution. It introduces a teardown mechanism in the test class and manages activity transition states in MainActivity using weak references. The review feedback suggests optimizing the retrieval of the Impeller backend to avoid duplicate expensive PackageManager metadata queries, and performing subclass-specific cleanup in cleanUpFlutterEngine before calling the superclass method.
- read backend only once in provideFlutterEngine - call super.cleanUpFlutterEngine after subclass cleanup
There was a problem hiding this comment.
Code Review
This pull request introduces Flutter engine caching for the Vulkan backend in MainActivity to prevent teardown crashes and optimize test execution, alongside proper cleanup handling in both MainActivity and FlutterActivityTest. The review feedback suggests exposing the cached engine key constant as internal from MainActivity and referencing it in the test class to avoid duplicating the string literal.
flutter/flutter@f7b66f3...cf9e8af 2026-07-12 [email protected] Flip from deprecated strict analysis modes to lint rules (flutter/flutter#187692) 2026-07-12 [email protected] Roll Skia from 6ecffccd32d5 to 8bf65996caba (5 revisions) (flutter/flutter#189333) 2026-07-11 [email protected] Roll Fuchsia Linux SDK from czpzDg9ABY2oKLAOY... to vhIlDkWIy21IrlB9E... (flutter/flutter#189309) 2026-07-11 [email protected] iOS: clean up swiftc.py after migration to target triples (flutter/flutter#189240) 2026-07-10 [email protected] Increase number of 'Mac tool_integration_tests' subshards from 5 to 10 (flutter/flutter#189040) 2026-07-10 [email protected] Fix PopupWindowControllerLinux missing WindowControllerLinux implementation (flutter/flutter#189189) 2026-07-10 [email protected] [android_hardware_smoke_test] Synchronize platform view compositing (flutter/flutter#189151) 2026-07-10 [email protected] UberSDF thin roundrect handling (flutter/flutter#189224) 2026-07-10 [email protected] Roll Skia from ab3a7b98c94d to 6ecffccd32d5 (15 revisions) (flutter/flutter#189270) 2026-07-10 [email protected] [skwasm][canvaskit] Honor Paint.filterQuality in Canvas.drawAtlas (flutter/flutter#186108) 2026-07-10 [email protected] Android_hardware_smoke_test: Cache flutter engine when running vulkan backend instrumented tests (flutter/flutter#189026) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Improvement related to #182123
Repeatedly creating and destroying the native Vulkan engine context across multiple sequential Activity scenarios triggered a race condition between Android's system compositor (
SurfaceControl/WindowManager) releasing platform view buffers in the background and the GPU driver cleaning up its device context. On devices using Mali GPUs (e.g., Pixel 7), this can result in a native crash:Abort message: 'FORTIFY: pthread_mutex_lock called on a destroyed mutex (...)'To avoid this crash, we cache the engine across Vulkan tests. But we can't do the same for OpenGLES tests.
When reusing a cached
FlutterEngineinstance across Activity transitions with OpenGL ES, the engine's EGL context fails to bind (eglMakeCurrentfails withEGL_BAD_ACCESS) to the new Activity's surface. This is because the context and surfaces are tied to the prior Activity/Window lifecycle. Launching a fresh engine instance for OpenGL ES avoids this failure.Pre-launch Checklist
///).