Repository navigation
fix: don't create a fallback map when a map-view factory has no map - #4419
Merged
Merged
Conversation
When the factory named by mapViewImpl returns nil/null (e.g. a stale car map id), RNMBXMapView stays empty instead of creating its own MapView; its children and commands become no-ops.
3 of 8 tasks
This branch was previously 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
When
mapViewImplnames a registered map-view factory (iOS) or external-map factory (Android) and it returns nil/null, for example for a stale car map id after the car map was replaced,RNMBXMapViewused to fall back to creating its own fullMapView.<CarMap>'s children then went into an invisible map that loaded the default style and fired events. Now the view stays empty: it logs one warning, children aren't added, props aren't applied, andMapViewcommands reject with "The MapView has no map". Remounting (e.g. with the new id) creates the map again.Normal MapViews are unaffected, and so is an Android
Factoryreturning null, which still falls back as before. iOS has only one factory kind, so there the rule applies to any registered factory that returns nil; an unregisteredmapViewImplstill falls back with the existing error log.This is SPI-only. It came up in the review of rnmapbox/navigation#17, whose
RNMBXNavigationCarMap.ktalready assumes this behavior. It's intended for 10.3.16.Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Screenshot OR Video
On the Android emulator, with the reproducer below:
nullext:1RNMBXMapView gets its owncom.mapbox.maps.MapView, renders the default style and the red circle, and firesonDidFinishLoadingStyle("stale external style loads: 1").MapView(checked withdumpsys activity top) and stays empty, with "stale external style loads: 0" and the warningThe nullext:1 factory has no map for this MapView, it stays empty. The normal map above it still renders.There are no unit tests: the Android JVM tests can't construct an
RNMBXMapView, and iOS has no native test target.yarn lint,yarn type:check,yarn unittestandyarn generateare clean; the example builds withassembleDebugand for the generic iOS simulator.Component to reproduce the issue you're fixing
Register a factory that returns null in
MainApplication.onCreate():Then render: