Repository navigation
fix(android): defer initial camera events until defaults are applied - #4348
Closed
RobJacobson wants to merge 1 commit into
Closed
RobJacobson wants to merge 1 commit into
RobJacobson wants to merge 1 commit into
Conversation
- Hold startup camera notifications until attachment callbacks finish applying the initial camera - Emit the current camera once after initialization and preserve subsequent camera events - Keep maps without a Camera and valid zero-coordinate camera positions working
4 of 8 tasks
Contributor
Author
|
Closing this duplicate in favor of #4355. That PR carries the same Android startup camera fix, adds focused CameraChangeEventGate tests, and now includes the validation record for this implementation family. |
This branch was successfully deployed
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.
Description
Fixes #4213
On Android,
onCameraChangedcan report[0, 0]before the childCameraappliesdefaultSettings. The native camera listener is registered during map creation, while the initial camera is applied through a callback posted after window attachment.Hold startup camera notifications until
lifecycle.afterAttachFromLooper()finishes applying the initial camera. If any camera changes occurred during initialization, emit one notification using the current camera state. Subsequent notifications follow the existing path. This also defers the legacyonRegionIsChangingcallback; maps without aCamerastill become ready, and configured or later moves to[0, 0]still produce callbacks.Validation
Verified in the example app on the
Medium_PhoneAndroid emulator with Fabric, React Native 0.84.1, Mapbox Maps SDK 11.23.1, and the 10.3.8 source tree. The issue reports React Native 0.83.6 and SDK 11.20.1; those exact versions were not rerun.[0, 0], zoom 3. Native logging showed two camera changes beforedefaultSettingswas applied.[-93.265, 44.9778], zoom 6. No camera callback at[0, 0]occurred. The idle camera was correct in all four runs.defaultSettingsdefaultSettingscentered at[0, 0]CameraCamerawithoutdefaultSettingsdefaultSettings[0, 0]:app:assembleDebug :rnmapbox_maps:testDebugUnitTest -PreactNativeArchitectures=arm64-v8a.yarn generatecompleted with no generated changes.yarn lintcompleted with existing warnings and no errors.yarn testrun passed 181 Jest cases and failed theUserLocationcase “renders with CircleLayers by default” with “No instances found.” All 14UserLocationcases passed in isolation; the full serial rerun,yarn unittest --runInBand, passed all 182 cases across 27 suites.Temporary reproducer and diagnostic logging were removed from the code change. The diff changes only
RNMBXMapView.kt.Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)iOS was not run. The new-feature sample checkbox is not applicable to this bug fix; the reproducer is included below.
Screenshot OR Video
This changes event ordering rather than visual layout. The captured event traces provide the before/after evidence.
Before and after camera events
Relevant fields from the recorded logs are shown below; bounds and process metadata are omitted. The timestamps are preserved.
Unfixed native trace:
Unfixed JavaScript callbacks:
Fixed JavaScript callbacks, first launch:
All four fixed launches:
[-93.265,44.9778][-93.265,44.9778][-93.265,44.9778][-93.265,44.9778]Component to reproduce the issue you're fixing
Replace
example/src/examples/BugReportExample.jswith the component below, rebuild the Android app, open the Bug Report example, and capture its camera and idle logs. The example app supplies its usual Mapbox access token. Repeat the launch on an unfixed build and on this branch.This is the issue's satellite map and camera configuration with logging of all camera states and an overlay that does not change the map's layout. On the unfixed build, the first camera callback can be
[0, 0]; with the fix, it is[-93.265, 44.9778]at zoom 6.Standalone BugReportExample reproducer