Fix Fit.LAYOUT artboard oversized on Android#209
Merged
Conversation
This was referenced Apr 10, 2026
c590fd9 to
5567aa0
Compare
Set layoutScaleFactor to device density before setRiveFile when the user hasn't set an explicit value. layoutScaleFactorAutomatic defaults to 1.0 and onMeasure may not fire before the render thread uses it. Fixes #206
5567aa0 to
0bf8e21
Compare
mfazekas
pushed a commit
that referenced
this pull request
Apr 13, 2026
🤖 I have created a release *beep* *boop* --- ## [0.4.2](v0.4.1...v0.4.2) (2026-04-13) ### Bug Fixes * Fit.LAYOUT artboard oversized on Android ([#209](#209)) ([8b4219d](8b4219d)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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.
BEGIN_COMMIT_OVERRIDE
fix: Fit.LAYOUT artboard oversized on Android (#209)
END_COMMIT_OVERRIDE
Fixes #206
Problem
Fit.LAYOUTintermittently renders the artboard at pixel dimensions instead of dp on Android (~50% repro rate, requires process restart).layoutScaleFactorAutomaticin rive-android defaults to1.0and is only corrected to device density inonMeasure(). Whenconfigure()callssetRiveFile(), the view hasn't been measured yet — but in bare Android this is harmless becauseonMeasureruns on the next Choreographer frame before the render thread picks up the first frame.In React Native,
configure()arrives from JS in a separate UI thread message, creating a wider window where the render thread can callresizeArtboard()with the bad default (1.0) beforeonMeasurecorrects it. Whether it does depends on thread scheduling at process start — hence the ~50% repro rate and the need for a full process restart to re-roll the dice.iOS doesn't have this issue because it initializes the scale factor at view init time.
Fix
Set
layoutScaleFactortoresources.displayMetrics.densityinconfigure()beforesetRiveFile(), when the user hasn't set an explicit value. This closes the race window.Also filed upstream: rive-app/rive-android#446 / rive-app/rive-android#447
Before / After
Reproducer
Requires navigation (screen transition) to trigger the race — mounting
Fit.Layoutviews on the initial screen doesn't reproduce because the timing window is too narrow. Repro rate ~50%, requires process restart.Expo Router reproducer (4 files)
app/index.tsx — home screen with navigation button
app/login.tsx — mounts Fit.Layout RiveView during screen transition
RiveBorderInput.tsx — the Fit.Layout component that gets oversized
Background.tsx — full-screen Fit.Cover background