Skip to content

feat(RasterSource): add prefetchZoomDelta and tileNetworkRequestsDela… - #4356

Open
oliverfernandez wants to merge 1 commit into
rnmapbox:mainfrom
oliverfernandez:feat/raster-source-prefetch-and-network-delay
Open

oliverfernandez wants to merge 1 commit into
rnmapbox:mainfrom
oliverfernandez:feat/raster-source-prefetch-and-network-delay

Conversation

@oliverfernandez

Copy link
Copy Markdown

Description

Added prefetchZoomDelta and tileNetworkRequestsDelay props to RasterSource. They expose two Mapbox v11 raster source options that are set today only by the SDK defaults:

  • prefetchZoomDelta: how many zoom levels above the current one are requested as placeholders while the current tiles load. Mapbox defaults to 4. 0 turns the prefetch off, which suits overlays such as weather radar where the placeholder is never visible.
  • tileNetworkRequestsDelay: milliseconds to wait before a tile's network request goes out while a gesture or camera animation is in progress. Tiles that leave the viewport before the delay elapses are never requested. Mapbox defaults to 0.

Both map straight to RasterSource.prefetchZoomDelta / tileNetworkRequestsDelay on iOS and RasterSource.Builder.prefetchZoomDelta() / tileNetworkRequestsDelay() on Android. They are read when the source is created, like the other source props.

Motivation: a weather app with 25 raster frames at one camera position. With the defaults, each frame also fetched parent tiles it never showed, and a pan requested tiles for positions the finger had already left. With these two options the same open costs a quarter of the tile requests.

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)

Testing notes: verified on iOS (v11, New Architecture) and compiled on Android (v11, New Architecture) through a production React Native 0.81 app that consumes this branch as a patch: the Fabric codegen picks up the new spec props, the component view and the Swift source compile, the Kotlin manager and source compile, and the raster tiles render on the iOS simulator with prefetchZoomDelta={0} and tileNetworkRequestsDelay={200}. A proxy capture on iOS confirmed that only tiles of the current zoom level are requested. Android was compile-checked only; the new example scene RasterSourceTileRequests is the place to confirm it at runtime.

Screenshot OR Video

No visual change. The example scene Fill/Raster Layer > Raster Source tile requests shows the props in use; compare the network log with Raster Source while panning.

…y props

Expose two Mapbox v11 raster source options that were not reachable from
JavaScript:

- prefetchZoomDelta: how many zoom levels above the current one are requested
  as placeholders while the current tiles load. 0 turns the prefetch off.
- tileNetworkRequestsDelay: milliseconds to wait before a tile's network
  request goes out during a gesture or camera animation, so tiles that leave
  the viewport first are never requested.

Both map straight to the native source builders on iOS and Android. Docs
regenerated with yarn generate, and a new example scene uses both props.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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