Skip to content

fix(android): stop leaking executor thread in getBitmapDrawable#805

Open
pataar wants to merge 1 commit intocallstack:mainfrom
pataar:perf/slider-native-marginal-fixes
Open

fix(android): stop leaking executor thread in getBitmapDrawable#805
pataar wants to merge 1 commit intocallstack:mainfrom
pataar:perf/slider-native-marginal-fixes

Conversation

@pataar
Copy link
Copy Markdown

@pataar pataar commented May 5, 2026

Summary:

ReactSlider.getBitmapDrawable creates Executors.newSingleThreadExecutor() per call and never shuts it down, so every setThumbImage call leaks the worker thread for the lifetime of the process. Wrapped the submit/get in a try/finally and shut down the executor once the bitmap decode is complete.

The submit-then-immediately-get() pattern itself is preserved — the off-thread decode is presumably there to keep BitmapFactory.decodeStream(new URL(uri).openStream()) off the main thread for StrictMode. Behaviour is unchanged; only the now-idle worker thread is reclaimed.

Test Plan:

The Android slider has no JVM unit tests in this repo, so verification is by inspection.

Recommended manual check: mount/unmount a slider with a thumbImage repeatedly and confirm the live thread count does not grow indefinitely (e.g. via Android Studio's Profiler).

ReactSlider.getBitmapDrawable creates a single-thread ExecutorService per call
and never shuts it down, so every setThumbImage call leaks the worker thread
for the lifetime of the process. Wrap the submit/get in a try/finally and
shut down the executor once the bitmap decode is complete.

Behaviour is unchanged; only the now-idle worker thread is reclaimed.
@pataar pataar force-pushed the perf/slider-native-marginal-fixes branch 2 times, most recently from f5fa3a5 to 2696bb8 Compare May 5, 2026 19:27
@pataar pataar changed the title perf(android): stop leaking executor thread; drop intermediate ArrayList fix(android): stop leaking executor thread in getBitmapDrawable May 5, 2026
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