cawfree / react-native-webassembly

⚛️ 🏎 WebAssembly for React Native powered by JSI.
https://twitter.com/cawfree
MIT License
291 stars 6 forks source link

Error when calling wasm generated from Rust code #13

Closed wkwi2r closed 1 year ago

wkwi2r commented 1 year ago

I'm using wasm-pack to generate the wasm from my Rust code which is the add two number function in the example. When I tried to load the wasm in my React-Native code, I encountered the following error: Any suggestion on how to solve this?

Compiling JS failed: 150636:23:';' expected Buffer size 7170249 starts with: 766172205f5f42554e444c455f535441

RCTFatal 28-[RCTCxxBridge handleError:]_block_invoke _dispatch_call_block_and_release _dispatch_client_callout _dispatch_main_queue_drain _dispatch_main_queue_callback_4CF CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE __CFRunLoopRun CFRunLoopRunSpecific -[NSRunLoop(NSRunLoop) runMode:beforeDate:] -[NSRunLoop(NSRunLoop) runUntilDate:] +[RNSplashScreen show] -[AppDelegate application:didFinishLaunchingWithOptions:] -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] -[UIApplication _runWithMainScene:transitionContext:completion:] -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] _UIScenePerformActionsWithLifecycleActionMask 101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] 186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] 64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.189 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] 92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke.59 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke _dispatch_client_callout _dispatch_block_invoke_direct FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ -[FBSSerialQueue _targetQueue_performNextIfPossible] -[FBSSerialQueue _performNextFromRunLoopSource] CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION CFRunLoopDoSource0 CFRunLoopDoSources0 __CFRunLoopRun CFRunLoopRunSpecific GSEventRunModal -[UIApplication _run] UIApplicationMain main start_sim 0x0 0x0

cawfree commented 1 year ago

Hey @wkwi2r, did you find a solution to this issue? Does this question on StackOverflow seem like the culprit?

wkwi2r commented 1 year ago

I've re-started from scratch and manage to get the example working. However, I'm only able to pass numbers to and fro the WASM function, still having runtime errors when passing string and byte array for example.