Skip to content
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

TurboModule which uses JSI crashes with this memory address 0x1 #13925

Open
jihoobyeon opened this issue Oct 4, 2024 · 5 comments
Open

TurboModule which uses JSI crashes with this memory address 0x1 #13925

jihoobyeon opened this issue Oct 4, 2024 · 5 comments
Assignees
Labels
Area: JSI Area: Turbo Modules bug New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric Workstream: Module Support Module developers have the requisite tooling and clear path for adding windows support to modules.
Milestone

Comments

@jihoobyeon
Copy link

jihoobyeon commented Oct 4, 2024

Problem Description

I'm trying to port BabylonReactNative to TurboModules,
but when I made codegen and run the app, it crashes with memory address of this(at facebook::jsi::Object) is 0x1 - absolutely abnormal address value.

I've also questioned it at Babylon.js forum, but there is no abnormal address value in BabylonNative part, so I guess JSI of RNW seems to be problematic, thus asking here.

This is the call stack:

BabylonModule.dll!facebook::jsi::Runtime::getPointerValue(const facebook::jsi::Pointer & pointer) line 81
BabylonModule.dll!winrt::Microsoft::ReactNative::JsiAbiRuntime::AsJsiObjectRef(const facebook::jsi::Object & obj) line 817
BabylonModule.dll!winrt::Microsoft::ReactNative::JsiAbiRuntime::getProperty(const facebook::jsi::Object & obj, const facebook::jsi::String & name) line 515
BabylonModule.dll!facebook::jsi::Object::getProperty(facebook::jsi::Runtime & runtime, const facebook::jsi::String & name) line 94
BabylonModule.dll!facebook::jsi::Object::getProperty(facebook::jsi::Runtime & runtime, const char * name) line 90
BabylonModule.dll!facebook::jsi::Object::getPropertyAsObject(facebook::jsi::Runtime & runtime, const char * name) line 174
BabylonModule.dll!facebook::jsi::Object::getPropertyAsFunction(facebook::jsi::Runtime & runtime, const char * name) line 188
BabylonModule.dll!napi_env__::napi_env__(facebook::jsi::Runtime & rt) line 51
BabylonModule.dll!Napi::Attach(facebook::jsi::Runtime & rt) line 7
BabylonModule.dll!BabylonNative::ReactNativeModule::ReactNativeModule(facebook::jsi::Runtime & jsiRuntime, std::function<void __cdecl(std::function<void __cdecl(void)>)> jsDispatcher) line 42

Steps To Reproduce

  1. Make a new arch RNW app.
  2. Add modules described below and run yarn react-native autolink-windows.
  3. Change App.tsx as below and run the app.
import { JSX, useEffect, useState } from 'react';
import { View } from 'react-native';
import { Camera, Scene } from '@babylonjs/core';
import { EngineView, useEngine } from '@babylonjs/react-native';

export default function App(): JSX.Element {
  const engine = useEngine();
  const [camera, setCamera] = useState<Camera>(null);

  useEffect(() => {
    if (engine) {
      const scene = new Scene(engine);
      scene.createDefaultCamera(true);
      setCamera(scene.activeCamera!);
    }
  }, [engine]);

  return (
    <View style={{ flex: 1 }}>
      <EngineView style={{ flex: 1 }} camera={ camera } />
    </View>
  );
}

Expected Results

Just run without error.

CLI version

14.1.0

Environment

System:
  OS: Windows 10 10.0.19045
  CPU: "(4) x64 AMD Ryzen 3 2200U with Radeon Vega Mobile Gfx  "
  Memory: 25.14 GB / 31.63 GB
Binaries:
  Node:
    version: 20.10.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 3.6.4
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 10.8.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    AllowAllTrustedApps: Enabled
    Versions:
      - 10.0.18362.0
      - 10.0.19041.0
      - 10.0.22000.0
      - 10.0.22621.0
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 17.11.35312.102 (Visual Studio Community 2022)
Languages:
  Java: 21.0.3
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.4
    wanted: 0.75.4
  react-native-windows:
    installed: 0.75.4
    wanted: ^0.75.4
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Community Modules

"@babylonjs/core": "^7.28.0",
"@babylonjs/react-native": "https://github.com/jihoobyeon/BRN-windows.git",
"@babylonjs/react-native-windows-module": "https://github.com/jihoobyeon/BRN-windows-module.git",
"@babylonjs/react-native-windows-view": "https://github.com/jihoobyeon/BRN-windows-view.git"

Target Platform Version

10.0.22621

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

Debug

Snack, code example, screenshot, or link to a repository

No response

@jihoobyeon jihoobyeon added the bug label Oct 4, 2024
Copy link

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Triage 🔍 New issue that needs to be reviewed by the issue management team (label applied by bot) label Oct 4, 2024
@chiaramooney chiaramooney added the Workstream: Module Support Module developers have the requisite tooling and clear path for adding windows support to modules. label Oct 4, 2024
@jonthysell jonthysell added Area: JSI Area: Turbo Modules and removed Needs: Triage 🔍 New issue that needs to be reviewed by the issue management team (label applied by bot) labels Oct 7, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric label Oct 7, 2024
@jonthysell jonthysell added this to the Backlog milestone Oct 7, 2024
@vmoroz
Copy link
Member

vmoroz commented Oct 10, 2024

@jihoobyeon, I will check it out next week.
Did you debug it yourself? What did you see under the debugger?

@vmoroz
Copy link
Member

vmoroz commented Oct 10, 2024

@jihoobyeon , where is the C++ code for the TurboModule and how is it being instantiated?
The repo that you pointed to has only a set of new JS files.
My understanding is that Babylon Native does not have it working for RNW, and I do not see how can you achieve it without changes to C++ code.

@jihoobyeon
Copy link
Author

@jihoobyeon , where is the C++ code for the TurboModule and how is it being instantiated? The repo that you pointed to has only a set of new JS files. My understanding is that Babylon Native does not have it working for RNW, and I do not see how can you achieve it without changes to C++ code.

C++ codes are located at branch module and view.
Yup, I knew it was a bad practice to split codes just by git branches, but I was on haste with a reallife issue at that time. I apologize. So I now made them to separate repo:
"@babylonjs/react-native-windows-module": "https://github.com/jihoobyeon/BRN-windows-module.git"
"@babylonjs/react-native-windows-view": "https://github.com/jihoobyeon/BRN-windows-view.git"

And yes, BabylonReactNative used to work for RNW, but broken after RNW 0.71.
Thus I am trying to fix C++ codes, but the very first error I encounterd is this this memory violation.

Debug console only says: exception throwed: read access violation. **pointer** was 0x1.
but at Visual Studio (the tab name is "auto" for Korean - I think it's translation error), this at line 94 of jsi-inl.h is 0x0000000000000001, thus results failing to read memory at JsiAbiApi.cpp.
So it seems to facebook::jsi::Object *obj not has been made while initialization.
I have to know what is that obj and why it is not properly made to take next step.

@jihoobyeon
Copy link
Author

@vmoroz , Have you checked it?
Did you find anything suspicious?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: JSI Area: Turbo Modules bug New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric Workstream: Module Support Module developers have the requisite tooling and clear path for adding windows support to modules.
Projects
None yet
Development

No branches or pull requests

4 participants