Skip to content

fix(android): support bundled images in ImageSource release builds - #4349

Merged
mfazekas merged 1 commit into
mainfrom
fix/android-imagesource-bundled-image
Oct 13, 2026
Merged

mfazekas merged 1 commit into
mainfrom
fix/android-imagesource-bundled-image

Conversation

@mfazekas

@mfazekas mfazekas commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #3671

In release builds a require()'d image reaches RNMBXImageSource as a drawable resource name instead of a Metro URL. setURL stored the resource id but nothing used it, and makeSource threw. The resource is now decoded with BitmapFactory.decodeResource and pushed to the source with Mapbox's ImageSource.updateImage once the source is in the style, and again on later url changes. 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

  • 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

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:

E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: java.lang.RuntimeException: ImageSource without URL not supported in v10, resourceId is not supported

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.js reproduces it in a release build (./gradlew :app:assembleRelease).

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
@mfazekas
mfazekas merged commit 67ea17b into main Oct 13, 2026
9 checks passed
@mfazekas
mfazekas deleted the fix/android-imagesource-bundled-image branch October 13, 2026 03:10

This branch was successfully deployed

1 active 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.

[Bug]: ImageSource crashes on Android in release mode

1 participant