Skip to content

fix(ios): size the legacy Metal drawable from the view's own bounds - #394

Closed
EQuimper wants to merge 1 commit into
rive-app:mainfrom
EQuimper:fix/ios-legacy-drawable-ancestor-transform
Closed

EQuimper wants to merge 1 commit into
rive-app:mainfrom
EQuimper:fix/ios-legacy-drawable-ancestor-transform

Conversation

@EQuimper

@EQuimper EQuimper commented Sep 24, 2026 •

Copy link
Copy Markdown

Summary

On devices where nativeScale != scale, legacy RiveViews render squashed when they are mounted under a rotated parent, and blank under a parent scaled to zero. That means Display Zoom, and iPhone mini and Plus models. This PR turns off MTKView's automatic drawable sizing on the legacy view and sizes the drawable from the view's own bounds × window.screen.nativeScale.

Closes #393.

Problem

MTKView computes its drawable size with per-axis factors. It derives them once, on the first window attach, by converting the screen bounds through every ancestor transform. A rotated ancestor at that moment leaves a non-uniform drawable for the view's whole lifetime, and Fit.Contain then squashes the artboard. A zero-scale ancestor gives an invalid drawable, which is the crash in rive-app/rive-ios#343 and a blank view since 6.2.1. The full breakdown is in #393.

Changes

ios/legacy/RiveReactNativeView.swift:

  • sets riveView.autoResizeDrawable = false when the view is created;
  • adds syncDrawableSize(), called from layoutSubviews and didMoveToWindow. It sets drawableSize to bounds × window.screen.nativeScale, rounded the way MTKView rounds, and skips empty bounds.

When nothing is transformed, the result is the same size MTKView would have picked.

Before / after

Testing

  • Shipped to TestFlight in a production app, through patch-package on 0.4.20 with RiveRuntime 6.23.1.
  • Verified on an iPhone 16 with Display Zoom (iOS 26), before and after, on views rotated by ±14°. The artboard is back to its own aspect ratio.
  • xcodebuild of the RNRive pod target passes, and SwiftLint reports no new warnings.
  • Not tested: the example apps in this repo, iPhone mini or Plus hardware, and the new backend (not touched).

Notes

  • The new, default backend is affected the same way: rive-ios RiveUIView creates a plain MTKView with automatic drawable sizing. The fix for that belongs in rive-ios, and I'm happy to open an issue there.
  • I can open the same change against release-v0.4, where the file is ios/RiveReactNativeView.swift.

MTKView's automatic drawable resize derives per-axis scale factors once,
on its first window attach when the screen's nativeScale differs from
the view's contentScaleFactor (Display Zoom, iPhone mini and Plus). It
computes them by converting the screen bounds through every ancestor
transform, so a rotated ancestor at that moment leaves a non-uniform
drawable for the view's lifetime and Fit.Contain squashes the artboard;
a zero-scale ancestor yields an invalid drawable (blank since rive-ios
6.2.1, see rive-app/rive-ios#343).

Turn autoResizeDrawable off on the legacy RiveView and set drawableSize
from its bounds times the window screen's nativeScale on layout and on
window changes.
@mfazekas

Copy link
Copy Markdown
Collaborator

Thanks much for the fix and the root-cause analysis! We've reported this upstream (rive-app/rive-ios#463), and rive-ios has fixed it in the SDK itself for both runtimes (rive-app/rive-ios@21e702d), expected in the next rive-ios release. Once we bump to that release this change won't be needed, so we'll close this PR then.

@EQuimper

Copy link
Copy Markdown
Author

@mfazekas perfect ! :) thanks

@mfazekas

mfazekas commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Closing in favor of #401: rive-ios 6.28.0 fixes this in the SDK for both the legacy and the new runtime, and I verified it on an iPhone 13 mini simulator with no wrapper changes (rotated and scale(0) views now get correctly sized drawables). Thanks again for the report, the root-cause analysis and the fix!

@mfazekas mfazekas closed this Oct 1, 2026
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.

[iOS] RiveView is squashed (or blank) under a rotated/scaled parent with Display Zoom and on iPhone mini/Plus

2 participants