Skip to content

ci: wait for maps to go idle before taking doc screenshots - #4404

Merged
mfazekas merged 2 commits into
mainfrom
ci/doc-screenshots-wait-idle
Oct 26, 2026
Merged

mfazekas merged 2 commits into
mainfrom
ci/doc-screenshots-wait-idle

Conversation

@mfazekas

@mfazekas mfazekas commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

The nightly doc screenshot run (docScreenshots.e2e.js) slept a fixed 1 s (3 s for disableSync examples) 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/CacheManagement with 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 the doc-screenshots build in ios-actions.yml, which the nightly Percy and manual workflows use), metro.config.js resolves @rnmapbox/maps in example/src to src/utils/MapsIdleTracker.tsx. Without it, the example app uses the plain @rnmapbox/maps and the test falls back to the fixed delay with a one-time warning. That module re-exports the library with a MapView that tracks onMapIdle (or onRegionDidChange) and onCameraChanged (or onRegionIsChanging), chaining any handlers the example passes. ExampleScreen renders an e2e-maps-idle view 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 set waitForMapIdle: false in their metadata and keep the fixed delay. Other examples that time out are logged by name. Library code is unchanged.

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

Screenshot OR Video

I ran the ios.release.ci Detox config locally on the iOS simulator against CacheManagement, ShowRegionDidChange, TwoByTwo, UserLocationUpdates, ImageOverlay and ViewportGestures: twice on main, and five times with this change.

  1. On main, CacheManagement came out different on each run: once at the initial zoom before the camera eased to z16, and once with almost no tiles loaded. ShowRegionDidChange also differed between runs.
  2. With this change, CacheManagement, ShowRegionDidChange, TwoByTwo, ImageOverlay and ViewportGestures were pixel-identical on every run, and CacheManagement showed the fully labelled z16 view. Idle typically arrived after 5–6 s for CacheManagement and ShowRegionDidChange and under 3.2 s for the others.
  3. In a full run with 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 have waitForMapIdle: 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.
  4. Without the env var, the built main.jsbundle doesn't contain the tracker's test IDs, and the test logs the warning and uses the fixed delays.

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.
@mfazekas
mfazekas merged commit a3831d5 into main Oct 26, 2026
10 checks passed
@mfazekas
mfazekas deleted the ci/doc-screenshots-wait-idle branch October 26, 2026 06:40

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant