fix(Android): remove the internal glsurface key before option parsing — forceGLSurfaceView currently breaks the map - #366
Open
kyhyeok wants to merge 1 commit into
Open
Conversation
platform_view.dart injects a "glsurface" entry into the platform view's creation params when NaverMap.forceGLSurfaceView is set, but the factory passed the whole map to NaverMapViewOptions.fromMessageable before reading that entry back. ApplyUtil.applyOptions iterates every key and throws NoSuchMethodException for keys it does not know, and optionApplyFuncMap has no "glsurface" entry — so the platform view failed to be created and the map rendered blank whenever forceGLSurfaceView was used. Read and remove the key before the option parser runs. Verified on a Galaxy A12 (Android 12 / API 31), Flutter 3.44.4, release build: before, the map area was blank with NoSuchMethodException in logcat and no NaverMapView log line; after, the map renders normally and no exception is thrown. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Problem
Passing
NaverMap.forceGLSurfaceViewon Android makes the platform view fail to be created. The map area renders blank (the Flutter overlays — logo, scale bar, controls — still draw, so it is easy to mistake for a styling problem) and logcat shows:NaverMapView's own log line (Installing custom TextureView driven invalidator./No TextureView found. Likely using the LEGACY renderer.) never appears —initis not reached.So the parameter does not work in production at all, not just in tests.
Cause
The plugin injects its own key into the creation params:
and the factory hands the whole map to the option parser before reading that key back:
NaverMapViewOptions.fromMessageable→naverMapOptionFromMessageable→ApplyUtil.applyOptionsiterates every entry and throwsNoSuchMethodExceptionfor keys it does not recognise:and
optionApplyFuncMaphas no"glsurface"entry. The plugin therefore trips on a key it added itself, on everyNaverMapthat passesforceGLSurfaceView.Fix
Read and remove the key before the option parser runs. Same three lines, reordered:
Types line up:
asNullableMap()returnsMap<String, Any?>, andfromMessageable(args: Map<String, Any?>)accepts the resultingMutableMap.Verification
Built and run on a Samsung Galaxy A12 (Android 12 / API 31), Flutter 3.44.4, release build:
NoSuchMethodExceptionin logcat, zeroNaverMapViewlog lines;I NaverMapView: Installing custom TextureView driven invalidator., no exception, map renders normally (tiles, clusters, my-location marker, labels), and 12 open/close cycles are flat on native heap.I did not add a regression test:
android/src/contains only amainsource set, so there is no Kotlin test target to put one in. I'd be glad to add one together with the test source set if you want it in this PR.Why this matters beyond the parameter itself
forceGLSurfaceViewis currently the only in-plugin way to opt out of the GLSurfaceView render view, and on API 30–32 that render path leaks the map's wholeViewtree and ~18 MB of native heap per open/close. Measurements, bytecode trace and the TextureView comparison are in #365.Thanks for maintaining this plugin — happy to adjust anything here (including the comment wording or dropping the comment entirely).