[Fix] Add non-destructive recovery for VirtualDisplay map freezes when returning from the Android background#61
Open
gunyu1019 wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an Android-specific, non-destructive recovery path for Kakao Map freezes caused by Flutter’s VirtualDisplay rehost behavior on Activity resume, while keeping a destructive MapView recreation path as an opt-in fallback.
Changes:
- Adds
recoverAndroidGLSurfaceViewOnResume(defaulttrue) and wires it through Flutter → Android to recover Kakao’s forked GLSurfaceView thread on reattach. - Demotes MapView recreation to an opt-in fallback (
recreateAndroidMapViewOnResume, defaultfalse) and preserves camera position across recreation. - Updates controller/overlay state to reset cleanly after native MapView recreation; updates widget tests accordingly.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/kakao_map_widget_test.dart | Adjusts Android params assertions (strips injected recovery flag) and adds coverage for recreation params. |
| lib/widget/map_widget.dart | Introduces new Android resume recovery/recreate options and injects them into platform creation params; resets controller state on repeated native onMapReady. |
| lib/controller/overlay/overlay_manager.dart | Allows overlay controllers to be re-initialized after native recreation (removes final). |
| lib/controller/controller_implement.dart | Adds controller reset routine to clear/reinitialize overlay state after native MapView recreation. |
| android/src/main/kotlin/kr/yhs/flutter_kakao_maps/views/KakaoMapViewFactory.kt | Plumbs new resume recovery/recreate options from creation params into KakaoMapView. |
| android/src/main/kotlin/kr/yhs/flutter_kakao_maps/views/KakaoMapView.kt | Implements container-based MapView hosting, delayed recreation, camera preservation, and GLSurfaceView recovery on reattach. |
| android/src/main/kotlin/kr/yhs/flutter_kakao_maps/model/KakaoMapOption.kt | Adds helper to recreate options while preserving camera position. |
| .gitignore | Ignores local Android engine debugging artifacts and normalizes .swiftpm/ entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+60
to
+67
| val pendingRecreate = recreateMapViewOnResume && wasActivityPaused | ||
| val recoveryActive = recoverGLSurfaceViewOnResume && !recreateMapViewOnResume && wasActivityPaused | ||
| isActivityResumed = true | ||
| if (pendingRecreate) { | ||
| wasActivityPaused = false | ||
| scheduleMapViewRecreation() | ||
| return | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Log
Root cause identified:
VirtualDisplayController.resetSurface()fully recreates the VirtualDisplay andSingleViewPresentationon every Activity resume, detaching/reattaching the PlatformView. This is an Android 14-only HardwareRenderer workaround (Workaround HardwareRenderer breakage in Android 14 flutter-team-archive/engine#52370) that runs on all API levels without a version gate.com.kakao.vectormap.graphics.gl.GLSurfaceView) pauses its GL thread on a non-finishing detach but never resumes it on reattach, andMapView.resume()only resumes the native renderer — it never wakes the GL thread — leaving the map permanently frozen.Changes:
recoverAndroidGLSurfaceViewOnResumeoption (defaulttrue): non-destructive recovery that detects the engine rehost and calls the fork'sGLSurfaceView.onResume()followed byMapView.resume(). NoonMapReadyre-fire; all registered overlays are preserved.recreateAndroidMapViewOnResumedefault fromtruetofalse: destructive MapView recreation is demoted to an emergency fallback.Issue Number
Checklist