Skip to content

fix(accesskey): make export dimensions compile-time constants#1039

Merged
bmc08gt merged 1 commit into
code/cashfrom
fix/accesskey-uninitialized-dimension-race
Jul 5, 2026
Merged

fix(accesskey): make export dimensions compile-time constants#1039
bmc08gt merged 1 commit into
code/cashfrom
fix/accesskey-uninitialized-dimension-race

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

The access key export dimensions (targetWidth/Height, logo, QR, text offsets) were instance vals, read by createBitmapForExport on dispatchers.IO. That work is kicked off from the init{} flow collector before the constructor finishes initializing the fields, publishing a half-built this to a background thread with no happens-before. The IO thread could then observe a field as its default 0, throwing "IllegalArgumentException: width and height must be > 0" — but only on release/R8 builds (isDebuggable=false); debug and minified-debug masked it via un-optimized codegen and timing.

Promote the dimensions to const val in a companion object so kotlinc inlines them at every use site — no instance fields left to race on. Also switch the entropy flow to mapNotNull.

Refs Bugsnag 6a457e5e.

The access key export dimensions (targetWidth/Height, logo, QR, text offsets)
were instance `val`s, read by createBitmapForExport on dispatchers.IO. That
work is kicked off from the init{} flow collector before the constructor
finishes initializing the fields, publishing a half-built `this` to a
background thread with no happens-before. The IO thread could then observe a
field as its default 0, throwing "IllegalArgumentException: width and height
must be > 0" — but only on release/R8 builds (isDebuggable=false); debug and
minified-debug masked it via un-optimized codegen and timing.

Promote the dimensions to `const val` in a companion object so kotlinc inlines
them at every use site — no instance fields left to race on. Also switch the
entropy flow to mapNotNull.

Refs Bugsnag 6a457e5e.

Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
@bmc08gt bmc08gt self-assigned this Jul 5, 2026
@bmc08gt bmc08gt merged commit 85571cf into code/cash Jul 5, 2026
3 checks passed
@github-actions github-actions Bot added type: fix Bug fix area: onboarding and removed type: fix Bug fix labels Jul 5, 2026
@bmc08gt bmc08gt deleted the fix/accesskey-uninitialized-dimension-race branch July 5, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant