fix(accesskey): fall back to raster logo when vector rasterization fails#1030
Merged
Conversation
Rasterizing the vector access-key logo via Drawable.toBitmap crashes on some budget OEM devices (e.g. Infinix X693, Vortex JK68) with "width and height must be > 0". The failure originates inside VectorDrawable's internal cache-bitmap allocation, not our dimensions — the values we pass (92x132) are valid, so it's a device-level defect in the vector->bitmap path. Add a pre-rasterized PNG fallback: try the vector first, and on failure retry with a BitmapDrawable (ic_flipcash_logo_raster), which goes through the far more robust decode/scale path and sidesteps the VectorDrawable cache entirely. If even that fails, render the recovery image without the logo instead of dropping the whole image, and report a non-fatal. Also removes the !! on the logo drawable, which was a latent NPE. Refs Bugsnag 6a47a1e0.
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.
Problem
Drawable.toBitmapon the vector access-key logo crashes on some budget OEMdevices (e.g. Infinix X693, Vortex JK68) with
java.lang.IllegalArgumentException: width and height must be > 0, seenunhandled in production (Bugsnag
6a47a1e0, and the same signature acrossseveral sibling groups).
Deobfuscating the R8-mapped stack for the crashing build put the failure in
BaseAccessKeyViewModel.createBitmapForExport— specifically the R8-inlinedDrawableKt.toBitmaponic_flipcash_logo. The logo is a tiny 92×132 bitmap,so this is not memory pressure. Our dimensions are valid positive
constants; the
> 0violation originates inside VectorDrawable's internalcache-bitmap allocation on these ROMs — a device-level defect in the
vector→bitmap path.
Fix
ic_flipcash_logo_raster, adrawable-nodpiasset reconstructed 1:1 from the vector geometry). It's aBitmapDrawable, sotoBitmaptakes thecreateScaledBitmapdecode/scalepath and never touches the VectorDrawable cache that crashes.
recoverCatchingwith the PNG → if eventhat fails, render the recovery image without the logo (key words + QR
still intact) and report a non-fatal, instead of dropping the whole image.
!!on the logo drawable (latent NPE).This complements #1027 (which catches the crash but discards the entire image);
here the image survives — with the logo on virtually all devices, and without
it only as a last resort.
Verification
./gradlew :apps:flipcash:shared:accesskey:compileDebugKotlin— BUILDSUCCESSFUL (regenerates
R, confirms the new drawable resolves).the fallback firing is only observable in the field once shipped; the PNG
path is structurally immune to the crash regardless.