Skip to content

fix(android): resize the render surface when the view size changes - #419

Open
mfazekas wants to merge 4 commits into
mainfrom
claude/fix-418-surface-resize
Open

mfazekas wants to merge 4 commits into
mainfrom
claude/fix-418-surface-resize

Conversation

@mfazekas

Copy link
Copy Markdown
Collaborator

On the new backend, onSurfaceTextureSizeChanged now resizes the RiveSurface through a reflective call to the Kotlin-internal RiveSurface.resize (resolved by name prefix and (int, int) signature, cached), mirroring what upstream RiveView does. It fails open: if the method is missing or throws, it logs a warning and keeps the old size. Fit.Layout resizes are also followed by a zero advance, since the render loop stops advancing a settled or paused state machine and the artboard resize would otherwise never apply. Adds an Issue #418 reproducer page.

Fixes #418

@Nezz

Nezz commented Oct 16, 2026

Copy link
Copy Markdown

Thanks for fixing this, I was about to make a report because I just came across the same issue on Android.

@sahzhang

Copy link
Copy Markdown

@mfazekas do you have an ETA for when this can be included in a released version?

@mfazekas
mfazekas force-pushed the claude/fix-418-surface-resize branch from 425f870 to d03aabc Compare October 28, 2026 08:41
@HayesGordon
HayesGordon requested a balanced review from Copilot October 28, 2026 09:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The layout advance can run before data binding, freeze responsive animations after resizing, or trigger state-machine transitions on paused views during unrelated prop updates.

3 open issues
What changed in this PR

This PR addresses issue #418 by updating Android’s experimental backend to resize the render surface when its view changes size, rather than retaining the creation-time dimensions.

Changes:

  • Adds cached reflective access to the SDK’s internal surface resize method, with warning logs on failure.
  • Advances Fit.Layout state machines by zero time after artboard resizing to apply layout updates.
  • Adds a reproducer comparing animated height changes with remounting.
File Description
example/​src/​reproducers/​Issue418SurfaceResize.tsx Adds height-toggle and remount controls to reproduce issue #418.
android/​src/​new/​java/​com/​rive/​RiveSurfaceResize.kt Adds the reflective surface-resize helper.
android/​src/​new/​java/​com/​rive/​RiveReactNativeView.kt Connects surface resizing and zero-time layout advancement.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Reloads can apply a stale resize to a new paused state machine, while layout changes can cause indefinite frame advances because SDK settling is not reset.

2 open issues
3 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A pending layout advance can run after switching away from Layout, causing a paused state machine to consume inputs or fire transitions.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Clear pending layout advance when switching to a non-Layout fit

android/​src/​new/​java/​com/​rive/​RiveReactNativeView.kt:357

If a paused Layout view is resized and its fit changes to a non-Layout fit before the next frame, the fit update does not reload the state machine, so this branch leaves the previous layout advance pending. The next frame then advances the paused machine and can consume inputs or fire transitions even though the current fit no longer needs that layout update. Clear the pending advance when leaving Layout.

2 resolved since last review

Review effort: Balanced

@mfazekas

Copy link
Copy Markdown
Collaborator Author

Re the previously missed issue in Copilot's last review (a pending layout advance surviving a switch to a non-Layout fit): fixed in 9f3ac21. resizeArtboardIfLayout() now clears layoutAdvancePending along with appliedLayout when the fit is not Layout.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Switching a paused view away from Fit.Layout leaves the artboard resized, causing other fits to render with incorrect bounds.

1 open issue

Review effort: Balanced

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.

[Android] Fit.Layout content stale after resize on the new backend (surface keeps creation size)

5 participants