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

React native new architecture not showing anything #3399

Open
jb-san opened this issue Nov 21, 2024 · 17 comments
Open

React native new architecture not showing anything #3399

jb-san opened this issue Nov 21, 2024 · 17 comments

Comments

@jb-san
Copy link

jb-san commented Nov 21, 2024

Im trying to run @react-three/fiber in a new expo project that is using the new architecture, but it does not show anything and when adding object like lighting it causes threejs to throw cannot read trim of undefined

it renders on web and android

I created a repro repo here:
https://github.com/jb-san/expo-52-three-fiber
run:

npm I
npm run ios

it has 3 pages

  1. using expo-gl and only threejs (works)
  2. using expo-three (works, but it does have a dependency on a lower threejs version, but even forcing the latest version works)
  3. using @react-three/fiber/native, (doesn't work)

I can get the PureThree.tsx to not render anything if I remove the style:{} on line 14

@jb-san
Copy link
Author

jb-san commented Nov 21, 2024

trying to make a custom renderer like this

 <Canvas
      style={{ flex: 1, backgroundColor: "black" }}
      gl={(canvas) => {
        const gl = canvas.getContext("webgl", { antialias: false })!;
        const renderer = new THREE.WebGLRenderer({
          canvas: {
            powerPreference: "high-performance",
            antialias: true,
            alpha: true,
            width: gl.drawingBufferWidth,
            height: gl.drawingBufferHeight,
            style: {},
            addEventListener: (() => {}) as any,
            removeEventListener: (() => {}) as any,
            clientHeight: gl.drawingBufferHeight,
          },
          context: gl,
        });
        renderer.setPixelRatio(1);
        renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight);

        return renderer;
      }}
      style={{ flex: 1, backgroundColor: "red" }}
    >...

to mimic the way the renderer is created in PureThree.tsx does not work

@anurbecirovic
Copy link

Same issue

@jb-san
Copy link
Author

jb-san commented Nov 22, 2024

After some digging, looks like it is running the renderer, updated my repo with an example where you can see that a useFrame is being called. I might be wrong, but I think there is something in the react-reconciler that is not working correctly with the new architecture

@jb-san
Copy link
Author

jb-san commented Nov 23, 2024

I have tried to find out why, but from logs it looks like the reconciler works, but I can not figure out why it wont render

@teubs
Copy link

teubs commented Dec 2, 2024

Thank you for your example repo - very helpful to see it's not my setup fault.
Is there any update? Having the same issue, but have to build up a new project using expo 52, but I am also in need of r3f. :/

@jb-san
Copy link
Author

jb-san commented Dec 2, 2024

I keep investigating this on my free time, the only conclusion I have is that for some reason it does not manage to get its render target (canvas), don't know why yet,
I also did a test where I updated to v9 of @react-three/fiber, and react 19, but that gave me a whole set of new errors from the its-fine provider, Ill update if I find a way

@busybox11
Copy link

Can also reproduce the same issue on iOS.
Running the exact same code on Web does work though.

@jb-san
Copy link
Author

jb-san commented Dec 11, 2024

strange.mov

It seams like the objects are there, the pointer events are there, but it does not render anything.
My guess is that it has to do with the reconciler

@cubevis
Copy link

cubevis commented Dec 12, 2024

Same issue :(

@TF002
Copy link

TF002 commented Dec 17, 2024

我也出现了同样的问题,expo@52 ,难道需要降成51吗?

@pauljnoble
Copy link

Same issue (and can also see that pointer events are active and being called). Thanks for setting up the repo to reproduce.

@dung-phan
Copy link

Is it possible to flag this as higher priority? Or nobody actually started a new project with new react native?

@CodyJasonBennett
Copy link
Member

This isn't a corporate support line but an issue tracker on open source software. There's no such thing as priority but opportunity rather. That's how open source software works. The issue lies upstream in expo-gl, but Expo themselves are not prioritizing graphics. If you want a company to reach out to or convey a business case, it would be with them. Here, and for now, work would be best effort but this is quite a Herculean one to maintain an entire graphics standard. I would strongly recommend a web view instead as I'm the only one to work in this area for some time, and the bedrock of react-native is extraordinarily primitive and yet brittle. You will not match performance or stability with either iOS Safari or Android engines in the current state of react-native, so I would only suggest it for enthusiast use.

@jb-san
Copy link
Author

jb-san commented Jan 23, 2025

Thanks for commenting @CodyJasonBennett, I would like to try to help out and solve this, will look into expo-gl side, do you have any hunches on where to look ? in the repro repo that I posted I got it working with expo-gl and pure threejs but not working with react-three-fiber.

Edit: works on a real device, simulator crashes now for some reason, I suspect the simulator crashing is a expo-gl issue

@jb-san
Copy link
Author

jb-san commented Feb 5, 2025

some progress, I followed @CodyJasonBennett excellent article https://codyb.co/articles/a-technical-breakdown-of-react-three-fiber and made my own tiny fiber like and got it to render after some changes, oh and I also had the trim of undefined from threejs, which I patched manually in the node_modules
https://github.com/jb-san/expo-52-three-fiber/tree/feature/baby3fiber
now I just need to find exactly what changes are needed and if they can be implemented without breaking anything

@CodyJasonBennett
Copy link
Member

CodyJasonBennett commented Feb 5, 2025

some progress, I followed @CodyJasonBennett excellent article https://codyb.co/articles/a-technical-breakdown-of-react-three-fiber and made my own tiny fiber like and got it to render after some changes, oh and I also had the trim of undefined from threejs, which I patched manually in the node_modules

This still sounds very broken.

in the repro repo that I posted I got it working with expo-gl and pure threejs

I missed this. Let me take a closer look. We should be getting the same behavior with the following:

<Canvas gl={{ antialias: false, powerPreference: 'default' }} dpr={1} events={null} />

@Drexregion
Copy link

I'm having the same issue for IOS, not sure if there is now a workaround for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants