Skip to content

Resize artboard every frame for Fit.LAYOUT - #450

Draft
mfazekas wants to merge 1 commit into
rive-app:masterfrom
mfazekas:fix/fit-layout-per-frame-resize
Draft

mfazekas wants to merge 1 commit into
rive-app:masterfrom
mfazekas:fix/fit-layout-per-frame-resize

Conversation

@mfazekas

Copy link
Copy Markdown
Contributor

Fixes #446 (issue 2)

Problem

State machine keyframes can overwrite m_Width every frame via CoreRegistry::setDouble(artboard, widthPropertyKey, ...) during advance(). Since resizeArtboard() only runs once (one-shot requireArtboardResize flag), the artboard stays at the keyframe value.

Reproduced with layout_test.riv — 9/10 launches show wrong artboard width.

For reference, iOS re-applies artboard dimensions every frame in drawRive rather than using a one-shot flag.

Changes

  1. RiveArtboardRenderer.draw() — call resizeArtboard() every frame when fit == Fit.LAYOUT
  2. RiveArtboardRenderer.resizeArtboard() — re-arm flag when artboard is null or surface is 0×0
  3. RiveAnimationView.onSurfaceTextureSizeChanged/Available() — set requireArtboardResize = true

Verified

layout_test.riv — 9/10 wrong before fix, 10/10 correct after.

State machine keyframes can overwrite artboard width via
CoreRegistry::setDouble during advance(). The one-shot
requireArtboardResize flag is already consumed, so the artboard stays
at the keyframe value. iOS re-applies artboard dimensions every frame
in drawRive; this matches that behavior.

Also re-arm requireArtboardResize when artboard is null or surface is
0x0, and set it in onSurfaceTextureSizeChanged/Available.

Fixes rive-app#446 (issue 2)
@Matt561

Matt561 commented Sep 17, 2026

Copy link
Copy Markdown

Hey @mfazekas, is there any way we can get this fix merged soon? I'm consistently running into inconsistent rendering using Fit.Layout on Android as well and very curious to see if this fixes the problem.

This branch has not been deployed

No deployments
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.

Fit.LAYOUT artboard size incorrect when onMeasure is deferred or state machine animates artboard width

2 participants