BabylonJS / BabylonReactNative

Build React Native applications with the power of Babylon Native
MIT License
379 stars 61 forks source link

3D View not been rendered when using windows npm package #364

Closed SergioRZMasson closed 2 years ago

SergioRZMasson commented 2 years ago

Overview

A user has reported on the forum that he was not able to get 3D view working when consuming Babylon React Native npm package for windows. At the time this was though as a versioning problem since @babylon/react-native-windows was using react-native-permissions@3.0.0 while all babylon react native packages were using version 2.1.0. Now that we have updated the package system and fixed this react-native-permissions version issue we will need to investigate why this is happening.

Link to the forum issue

Steps to repro

CedricGuillemet commented 2 years ago

I managed to get the project linked in the forum thread to work. First, the package.json where I edited the dependencies and looks like this:

  "dependencies": {
    "@babylonjs/core": "^5.0.0",
    "@babylonjs/loaders": "^5.0.0",
    "@babylonjs/react-native": "1.0.1",
    "@react-native-community/slider": "^4.2.1",
    "react": "17.0.2",
    "react-native": "0.65.2",
    "@babylonjs/react-native-windows-0-65": "1.0.1",
    "react-native-permissions": "^3.0.0",
    "react-native-windows": "^0.65.6"
  },

Then, disable web debugger in app.cpp

#if BUNDLE
    JavaScriptBundleFile(L"index.windows");
    InstanceSettings().UseWebDebugger(false);
    InstanceSettings().UseFastRefresh(false);
#else
    JavaScriptBundleFile(L"index");
    InstanceSettings().UseWebDebugger(**false**);
    InstanceSettings().UseFastRefresh(true);
#endif

@ryantrem IIRC, there is an issue regarding debugger support. I couldn't find it. Do you remember it?

ryantrem commented 2 years ago

With classic RN debugging, it runs all the JS code remotely on the dev machine rather than on the device, which is incompatible with anything using JSI (it will slowly be deprecated as TurboModules and Fabric gain adoption). But in that case, we have code that detects classic debugging is enabled (which works on Android/iOS, but perhaps not Windows), and show an error. If this debug mode was enabled, and we didn't properly detect it, it's possible that we are silently failing somewhere due to a null JSI pointer or something like that.

CedricGuillemet commented 2 years ago

User was able to get it to run properly. Closing.