Repository navigation
fix(android): load require()'d 3D models in release builds - #4434
Merged
Merged
Conversation
4 of 8 tasks
In release builds React Native ships non-image assets as res/raw resources referenced by a bare name, which Mapbox can't load as a model. Copy them to a cache file with a glb/gltf extension for LocationPuck and Models. Fixes #4433
mfazekas
force-pushed
the
fix/android-glb-require-release
branch
from
November 4, 2026 13:28
11671cf to
55bbdbb
Compare
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
Fixes #4433
In Android Release builds React Native ships non-image assets in
res/raw, soImage.resolveAssetSource(require('./car.glb'))returns just a resource name likesrc_assets_sportcar.LocationPuck(model.uri) andModelspassed that name to Mapbox, which fails withUnknown model file type: src_assets_sportcar. Bare names that match a raw resource are now copied once per process tocacheDir/rnmbx-models/<name>.glb(or.gltfwhen the file lacks the glb magic) and passed as afile://URL. URLs with a scheme (Metrohttp://in Debug,asset://,https://) are passed through as before. iOS is not affected, its resolved asset URLs already point into the bundle with the extension.Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Screenshot OR Video
Reproducer below on an Android 14 arm64 emulator (Pixel 6), Release build, each stage held 8 s:
require('…glb')E/Mapbox [maps-core]: Unknown model file type: src_assets_sportcarasset://sportcar.glbrequire('…glb')asset://sportcar.glbDebug build with Metro on this PR: both
requirestages render, no model errors.yarn lint,yarn type:checkandyarn unittestpass.Component to reproduce the issue you're fixing
Needs
sportcar.glb(fromexample/src/assets) next to it, and a copy inandroid/app/src/main/assets/for theasset://stages. Build in Release.