fix: nullPointerException in GroupView when drawing bitmap on Android 10 and older #2694
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.
Summary
Open Issue: isRecycled() on a null object reference
This PR addresses a sporadic crash that occurs specifically on Android 10 (API 29) and older when rendering SVGs.
Although the code already handles the mLayerBitmap being null in an earlier section, the bitmap can still become null on Android 10 and below due to memory pressure or race conditions, ultimately leading to a crash.
Differences in how Bitmap memory handled and Canvas drawing operations are handled in these versions, make them more susceptible to this issue.)
Reference: Android Bitmap Memory Management
Test Plan
Unfortunately, it is bit hard to recreate this behaviour and it is very sporadic.
I have patched this change in my app, and it has produced positive results. both for me and for some other users as well.
(#2609 (comment))
What's required for testing (prerequisites)?
What are the steps to reproduce (after prerequisites)?
Compatibility
Checklist
README.md
__tests__
folder