-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime crash on some devices if a parent has zero scale transform #343
Comments
@ghugues Thanks for sending this over, and providing a sample app. I also appreciate the open pull request, it's helpful insight. I've brought this up internally to decide where the right fix it. It could be fixed at the iOS runtime level, as you've showcased in your pull request, but there might be a lower-level fix we could also provide. Just double checking with the team. |
This pull request fixes some crashes (see [rive-ios #343](#343)) where the (drawable) size of the underlying view was not within the bounds within which Metal is capable of drawing. Possible conditions: - Width or height of the view is 0 - Transform of the view is x / y scale 0 The maximum allowed drawable sizes are based on [this Apple document](https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf). See: page 7. Essentially, before every draw, we now check whether we _can_ draw via Metal based on the size of the view, as well as the provided drawable size of the underlying Metal view. If not, we do an early return and no drawing happens. Unit tests have also been added for a few main scenarios under which this could occur. Diffs= fab89ebbba Validate rect and drawable size before drawing on iOS (#8334) Co-authored-by: David Skuza <[email protected]>
@ghugues This should now be fixed in v6.2.1, released earlier today. |
Description
On at least 1 device that I own (iPhone 12 mini running iOS 17.7), Rive crashes at runtime because of an invalid texture size.
Repro project
Link to sample project : RiveCrashTest.zip
Simplified repro code (note that the project has more details):
Run the application on an iPhone 12 mini with iOS 17.7 and the application will crash after outputting:
The stack trace is the following:
Notice the scale transform with a scale of zero on the parent view of the rive view. This is the reason for the invalid
drawableSize
. Without this transform, everything works as expected. The same problem occurs if the transform is on any parent view up the hierarchy, it doesn't have to be the direct superview.Expected behavior
The application should not crash. Because it is unclear why the
drawableSize
has an infinite size on some devices (and may be a bug in the Metal framework), the rive metal view should perform checks on thedrawableSize
before drawing. In the same way it already checks that the size is not zero, it should also check for infinite, nan, etc. values that could cause a crash down the line.Edit: After further testing, it appears that using a zero scale is just an extreme case of a broader issue. Any small scale transform on a parent view will produce a drawable size larger than the maximum texture size supported by the GPU and trigger a crash (even a 0.1 scale can trigger this crash). So although proper checks on the drawable size will avoid a crash, this could still leave the door open to performance problems by servicing a drawable size way bigger than actually necessary.
Device & Versions
The crash occurs at least on an iPhone 12 mini running iOS 17.7.
The crash does not occur on an iPhone 14 Pro running iOS 17.2.1.
Without additional testing on more devices, it is unclear what combination of device and iOS version causes the crash.
The text was updated successfully, but these errors were encountered: