rive-app / rive-app/rive-react-native

iOS Crash: Metal validation failure in RiveRuntime during drawIndexedPrimitives [Debug]

Open
#415 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
783
Forks
81
Avg merge
3d 6h
Merged PRs (30d)
3

Description

Description

We are experiencing a reproducible crash on iOS related to Metal validation when using rive-react-native. The crash occurs on the main thread during rendering and appears to originate from RiveRuntime’s Metal render path.

The crash is triggered by a Metal assertion failure during drawIndexedPrimitives, eventually calling abort().

Provide a Repro
  1. Run the app on iOS Simulator DEBUG
  2. App crashes on first launch only, during initial render
  3. Relaunch the app without reinstalling is OK
Expected behavior

Rive animations should render without triggering Metal validation errors or aborting the app.

Additional context
Thread 0 Crashed: Dispatch queue: com.apple.main-thread

0   ???                            0x1000daae0 ???
1   ???                            0x106c2df4c ???
2   libsystem_pthread.dylib        0x1256e7b66 pthread_kill + 259
3   libsystem_c.dylib              0x1221f296e abort + 134
4   libsystem_c.dylib              0x1221f1b66 __assert_rtn + 314
5   Metal                          0x11a1a4e7e MTLReportFailure.cold.1 + 41
6   Metal                          0x11a1779b6 MTLReportFailure + 512
7   Metal                          0x11a16b3b2 _MTLMessageContextEnd + 1294
8   MetalTools                     0x136f7e8ec -[MTLDebugRenderCommandEncoder validateCommonDrawErrors:] + 2712
9   MetalTools                     0x136f7dd50 -[MTLDebugRenderCommandEncoder validateCommonDrawErrors:instanceCount:baseInstance:maxVertexID:] + 1305
10  MetalTools                     0x136f7f4e7 -[MTLDebugRenderCommandEncoder validateDrawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:function:] + 314
11  MetalTools                     0x136f7f5b5 -[MTLDebugRenderCommandEncoder drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:] + 71
12  GPUToolsCapture                0x1098795ea -[CaptureMTLRenderCommandEncoder drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:] + 198
13  RiveRuntime                    0x11b58ee51 rive::gpu::RenderContextMetalImpl::flush(rive::gpu::FlushDescriptor const&) + 7393
14  RiveRuntime                    0x11b5884a3 rive::gpu::RenderContext::flush(rive::gpu::RenderContext::FlushResources const&) + 7715
15  RiveRuntime                    0x11b2e53e8 -[RiveRendererContext endFrame:withCompletion:] + 156
16  RiveRuntime                    0x11b2dd1a5 -[RiveRendererView drawInRect:withCompletion:] + 454
17  RiveRuntime                    0x11b2dd29b -[RiveRendererView drawRect:] + 104
18  RiveRuntime                    0x11b2f281b 0x11b2da000 + 100379
19  MetalKit                       0x1097bbaf3 -[MTKView draw] + 142
20  MetalKit                       0x1097b7e99 -[MTKViewDisplayLinkTarget draw] + 34
21  QuartzCore                     0x11b8054cd CA::Display::DisplayLinkItem::dispatch_ + 45
22  QuartzCore                     0x11b801027 CA::Display::DisplayLink::dispatch_items + 1029
23  QuartzCore                     0x11b80828a CA::Display::DisplayLink::dispatch_deferred_display_links + 368
24  UIKitCore                      0x15b935bf7 _UIUpdateSequenceRun + 55
25  UIKitCore                      0x15c6a3eed schedulerStepScheduledMainSection + 184
26  UIKitCore                      0x15c6a3027 runloopSourceCallback + 68
27  CoreFoundation                 0x124ccaff8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
28  CoreFoundation                 0x124ccaf3a __CFRunLoopDoSource0 + 157
29  CoreFoundation                 0x124cca78f __CFRunLoopDoSources0 + 311
30  CoreFoundation                 0x124cc4f9a __CFRunLoopRun + 973
31  CoreFoundation                 0x124cc47c5 CFRunLoopRunSpecific + 536
32  GraphicsServices               0x1336bdc09 GSEventRunModal + 137
33  UIKitCore                      0x15c7bf248 -[UIApplication _run] + 875
34  UIKitCore                      0x15c7c43cf UIApplicationMain + 123
Device & Versions
  • Device: iOS 18.6 simulator
  • React Native: 0.81.4
  • rive-react-native: 9.7.1, 9.8.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at RiveRuntime's RenderContextMetalImpl::flush, following the call from RiveRendererView drawInRect:withCompletion: during the first DEBUG render. Reproduce on the iOS 18.6 simulator with React Native 0.81.4 and rive-react-native 9.7.1 or 9.8.0, then inspect the Metal validation failure around drawIndexedPrimitives. Done means the first launch renders without the validation abort and relaunch behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, react-native, typescript
Domain
computer-graphics, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.