fix(widget): avoid recycling aliased source bitmap for 2:3 covers (#4850)
Bitmap.createBitmap returns the same immutable instance when the center-crop covers the whole source, which happens for covers that decode to exactly 2:3. writeThumbnail then recycled that instance before createScaledBitmap used it, crashing with "cannot use a recycled source in createBitmap". Guard the recycle the same way the scaled vs cropped case is already guarded, and add an instrumented regression test. Also bundles a pending widget debugging note and a regenerated fastlane README that were staged in the working tree. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+5
-1
@@ -57,7 +57,11 @@ object ReadingWidgetStore {
|
||||
val cropX = (srcW - cropW) / 2
|
||||
val cropY = (srcH - cropH) / 2
|
||||
val cropped = Bitmap.createBitmap(bitmap, cropX, cropY, cropW, cropH)
|
||||
bitmap.recycle()
|
||||
// createBitmap returns the SAME instance when the crop covers the whole
|
||||
// (immutable) source — i.e. covers already at exactly 2:3. Recycling here
|
||||
// would recycle `cropped` too and crash createScaledBitmap below with
|
||||
// "cannot use a recycled source". Mirror the scaled !== cropped guard.
|
||||
if (cropped !== bitmap) bitmap.recycle()
|
||||
|
||||
// Scale the cropped bitmap to the target size.
|
||||
val scaled = Bitmap.createScaledBitmap(cropped, THUMB_WIDTH, THUMB_HEIGHT, true)
|
||||
|
||||
Reference in New Issue
Block a user