Repository navigation
fix(android): support bundled images in ImageSource release builds - #4349
Merged
Merged
Conversation
In release builds require()'d images reach ImageSource as drawable resource names instead of Metro URLs, and makeSource threw. Decode the resource into a bitmap and push it with ImageSource.updateImage. Fixes #3671
This branch was successfully 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 #3671
In release builds a
require()'d image reachesRNMBXImageSourceas a drawable resource name instead of a Metro URL.setURLstored the resource id but nothing used it, andmakeSourcethrew. The resource is now decoded withBitmapFactory.decodeResourceand pushed to the source with Mapbox'sImageSource.updateImageonce the source is in the style, and again on laterurlchanges. A resource that fails to decode is logged as a warning instead of crashing. Decoding stays on the UI thread; overlay-sized images decode quickly enough that moving it off-thread didn't seem worth the extra complexity.Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Screenshot OR Video
Tested with Fill/Raster Layer > Image Overlay in the example app on an Android emulator (API 34, arm64).
Before, on a release build from main, opening the example crashes:
After, on a release build: the radar overlay renders, the frames alternate every second, and "Dynamic coordinates" moves the overlay. Logcat shows no errors. The debug build, which loads the image from Metro, still renders the same way.
Component to reproduce the issue you're fixing
The existing
example/src/examples/FillRasterLayer/ImageOverlay.jsreproduces it in a release build (./gradlew :app:assembleRelease).