rive-app / rive-ios

iOS runtime for Rive
MIT License
515 stars 58 forks source link

Yoga symbols collision #345

Open alextoudic opened 1 month ago

alextoudic commented 1 month ago

Description

I'm experiencing an EXC_BAD_ACCESS error with YGNodeStyleSetMinWidth when using use_frameworks! :linkage => :static in a project that uses Yoga for layout (specifically with React Native)

Provide a Repro

You can find the reproduction setup here: https://github.com/alextoudic/rive-yoga-collision-repro/tree/main/ios

Expected behavior

Both the Rive runtime and React Native should function correctly, using their respective Yoga symbols as intended

Screenshots

image

Stack trace:

* thread #8, queue = 'com.facebook.react.ShadowQueue', stop reason = EXC_BAD_ACCESS (code=1, address=0x104100)
    frame #0: 0x0000000000104100
    frame #1: 0x000000010620578c RiveRuntime`YGNode::markDirtyAndPropagate() + 36
  * frame #2: 0x00000001094d3140 YogaCollision.debug.dylib`-[RCTShadowView layoutWithMinimumSize:maximumSize:layoutDirection:layoutContext:](self=0x000000010661c590, _cmd="layoutWithMinimumSize:maximumSize:layoutDirection:layoutContext:", minimumSize=(width = 0, height = 0), maximumSize=(width = 402, height = 874), layoutDirection=UIUserInterfaceLayoutDirectionLeftToRight, layoutContext=RCTLayoutContext @ 0x000000016b97df70) at RCTShadowView.m:268:5
    frame #3: 0x00000001094c1330 YogaCollision.debug.dylib`-[RCTRootShadowView layoutWithAffectedShadowViews:](self=0x000000010661c590, _cmd="layoutWithAffectedShadowViews:", affectedShadowViews=0x000060000214ecb0) at RCTRootShadowView.m:35:3
    frame #4: 0x00000001094e7014 YogaCollision.debug.dylib`-[RCTUIManager uiBlockWithLayoutUpdateForRootView:](self=0x000060000291bbf0, _cmd="uiBlockWithLayoutUpdateForRootView:", rootShadowView=0x000000010661c590) at RCTUIManager.m:549:3
    frame #5: 0x00000001094ed104 YogaCollision.debug.dylib`-[RCTUIManager _layoutAndMount](self=0x000060000291bbf0, _cmd="_layoutAndMount") at RCTUIManager.m:1126:22
    frame #6: 0x00000001094ecfa8 YogaCollision.debug.dylib`-[RCTUIManager batchDidComplete](self=0x000060000291bbf0, _cmd="batchDidComplete") at RCTUIManager.m:1109:3
    frame #7: 0x000000010943b114 YogaCollision.debug.dylib`__32-[RCTCxxBridge batchDidComplete]_block_invoke(.block_descriptor=0x0000600000ce0c30) at RCTCxxBridge.mm:1514:13
    frame #8: 0x0000000104e6cec0 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #9: 0x0000000104e6e7b8 libdispatch.dylib`_dispatch_client_callout + 16
    frame #10: 0x0000000104e76aac libdispatch.dylib`_dispatch_lane_serial_drain + 912
    frame #11: 0x0000000104e777b0 libdispatch.dylib`_dispatch_lane_invoke + 420
    frame #12: 0x0000000104e841f0 libdispatch.dylib`_dispatch_root_queue_drain_deferred_wlh + 324
    frame #13: 0x0000000104e8375c libdispatch.dylib`_dispatch_workloop_worker_thread + 732
    frame #14: 0x0000000104f07814 libsystem_pthread.dylib`_pthread_wqthread + 284

Device & Versions (please complete the following information)

Additional context

The reproduction project is built using Expo with a patched version of rive-react-native to ensure the latest RiveRuntime version (the issue persists with or without this patch). This problem only arises when using use_frameworks! :linkage => :static, which is necessary in my case to integrate @react-native-firebase

I previously commented on this issue but believe this problem may be more related to the loading of Rive's Yoga symbols in a project with overlapping Yoga dependencies when libraries are not dynamically linked. Any insights from iOS developers would be greatly appreciated

Maniae commented 2 weeks ago

I'm wondering if a static framework version as suggested in https://github.com/rive-app/rive-ios/issues/336 would fix the issue ? Currently, it makes Rive unusable on ios with React Native if React-Native-Firebsae (a very common library) or other static framework is used

luigi-rosso commented 2 weeks ago

We have a renames header that we use to help avoid collisions like this.

We might need to add some symbols to it @dskuza.

Or, are we somehow disabling this on iOS? https://github.com/rive-app/rive-runtime/blob/main/dependencies/premake5_yoga_v2.lua

https://github.com/rive-app/rive-runtime/blob/main/dependencies/rive_yoga_renames.h

luigi-rosso commented 2 weeks ago

Looks like we are in fact missing YGNodeStyleSetMinWidth, and potentially more.

Maniae commented 2 weeks ago

I see the symbol on this line: https://github.com/rive-app/rive-runtime/blob/6f82f888172a8bb0ce16c1ff5b818156b326fad6/dependencies/rive_yoga_renames.h#L229

I'm not sure how the runtime is compiled, but I noticed the premake5_yoga_v2 script is called with the option --no-yoga-renames https://github.com/rive-app/rive-runtime/blob/6f82f888172a8bb0ce16c1ff5b818156b326fad6/dependencies/gen_yoga_renames/gen_renames.sh#L41

(It is then called again "just to examine the exported symbols...")

maximilianhagerf commented 1 week ago

Any update on this or a fix? Ran into the same issue with Expo SDK 51 with firebase and rive-react-native 6.0.4...

Maniae commented 1 week ago

Is this commit related ? https://github.com/rive-app/rive-runtime/commit/d3e4bcf2faa7abcdccdaa660c65a064dc2ea9b49 👀