Skip to content

Commit

Permalink
Fix Apple runtime crashes on Macs with non-Apple-Silicon GPUs
Browse files Browse the repository at this point in the history
This removes some legacy code that prevented the correct factory from being initialized when used on Macs with non-Apple-Silicon GPUs. Additionally, it removes explicitly setting the storage mode, which was causing Metal API validation to fail on non-Apple-Silicon GPU Macs.

## Storage Mode

Explicitly setting the storage mode to shared has been removed. This has no impact on iOS. For macOS, this defaults to managed, which should be appropriately handled by the C++ runtime, per Chris.

Per the docs for `MTLTextureDescriptor.storageMode`:

> In iOS and tvOS, the default value is MTLStorageMode.shared. In macOS, the default value is MTLStorageMode.managed.

## Testing

These changes were tested on an i9 Intel Mac against a file that was reproducibly causing crashes. Post-changes, the file no longer crashes.

Diffs=
56d95d200 Fix Apple runtime crashes on Macs with non-Apple-Silicon GPUs (#8301)

Co-authored-by: David Skuza <[email protected]>
  • Loading branch information
dskuza and dskuza committed Oct 8, 2024
1 parent 2c91a6a commit ae025ed
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ab13be54df9e69b44581d0e3fd8c6069e34d7528
56d95d2006868350ebb0c080447d07647d1a5855
5 changes: 0 additions & 5 deletions Source/Renderer/RenderContextManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ @implementation RiveRendererContext

static std::unique_ptr<rive::gpu::RenderContext> make_pls_context_native(id<MTLDevice> gpu)
{
if (![gpu supportsFamily:MTLGPUFamilyApple1])
{
NSLog(@"error: GPU is not Apple family");
return nullptr;
}
return rive::gpu::RenderContextMetalImpl::MakeContext(
gpu, rive::gpu::RenderContextMetalImpl::ContextOptions());
}
Expand Down
2 changes: 1 addition & 1 deletion submodules/rive-runtime

0 comments on commit ae025ed

Please sign in to comment.