Repository navigation
ci: wait for maps to go idle before taking doc screenshots - #4404
Merged
Merged
Conversation
The doc screenshot test slept a fixed 1 s (3 s without Detox sync) after opening an example, which often captured the map mid camera animation or before tiles and labels loaded, producing flaky Percy diffs. Examples now get a MapView (via a Metro redirect in the example app) that tracks onMapIdle/onCameraChanged, and the example screen renders an e2e-maps-idle marker once all mounted maps are idle. The test waits for it, falling back to taking the screenshot after 20 s.
The example app uses the plain @rnmapbox/maps by default. The doc screenshot CI build sets RNMBX_E2E_MAPS_IDLE=1, and docScreenshots.e2e.js falls back to the fixed delay with a warning when the tracker is missing. Examples that follow the user location never go idle, so they set waitForMapIdle: false in their metadata and skip the idle wait.
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
The nightly doc screenshot run (
docScreenshots.e2e.js) slept a fixed 1 s (3 s fordisableSyncexamples) before each screenshot, so maps were often captured mid camera animation or before tiles and labels loaded. That caused flaky Percy diffs, e.g.doc/CacheOffline/CacheManagementwith and without the street and POI labels.The test now waits until the maps are idle. When the example app is bundled with
RNMBX_E2E_MAPS_IDLE=1(set for thedoc-screenshotsbuild inios-actions.yml, which the nightly Percy and manual workflows use),metro.config.jsresolves@rnmapbox/mapsinexample/srctosrc/utils/MapsIdleTracker.tsx. Without it, the example app uses the plain@rnmapbox/mapsand the test falls back to the fixed delay with a one-time warning. That module re-exports the library with aMapViewthat tracksonMapIdle(oronRegionDidChange) andonCameraChanged(oronRegionIsChanging), chaining any handlers the example passes.ExampleScreenrenders ane2e-maps-idleview once every mounted map is idle, and the test waits for it with a 20 s fallback timeout. With several maps (TwoByTwo) it waits for all of them. A camera change resets the idle state, so examples that move the camera after their first idle (follow user location, camera animations) are also covered. Examples that follow the user location never go idle, so they setwaitForMapIdle: falsein their metadata and keep the fixed delay. Other examples that time out are logged by name. Library code is unchanged.Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Screenshot OR Video
I ran the
ios.release.ciDetox config locally on the iOS simulator against CacheManagement, ShowRegionDidChange, TwoByTwo, UserLocationUpdates, ImageOverlay and ViewportGestures: twice on main, and five times with this change.RNMBX_E2E_MAPS_IDLE=1, the 12 examples that follow the user location (the UserLocation group, ShowMap, ShowMapLocalStyle, MapFps, MapUnMount, MapAndRNNavigation) hit the 20 s timeout. Those now havewaitForMapIdle: false. Camera/Fit timed out once but went idle on 4 later runs, so it isn't flagged. All other examples were idle within 5.6 s.main.jsbundledoesn't contain the tracker's test IDs, and the test logs the warning and uses the fixed delays.