r/reactnative • • 2d ago

Question Making a 3D game with React Native

I've been writing React Native for many years, and for the last year or two I've been really into making games. I made a few with expo-gl and Skia, and they turned out pretty well. Of course I wrote my own tools to measure FPS on each screen and kept optimizing those parts. My first versions crashed a lot. Now my games are pretty stable.

That gave me the courage to try a 3D game, so I combined Three.js with React Native. I'll be honest: after the first attempts I lost my motivation. I told myself "3D just doesn't work with React" and put the project on hold. Then the excitement came back and I started again. I worked really hard on optimization and finally got to a point I'm happy with.

I also tested it on cheap Android phones and the results were good, but I didn't want to take any risks for the launch, so for now it's only out on iPhone.

Have any of you tried making a 3D game with React Native? What problems did you run into, and how did you solve them?

My game:
https://apps.apple.com/app/id6830497300

6 Upvotes

13 comments sorted by

2

u/dawedev 2d ago

Did you run into GC stutters from allocating Vector3/Matrix4 inside the frame loop? On Hermes that tends to show up as random hitches, and reusing a few scratch objects fixes most of it. InstancedMesh for anything repeated also cuts draw calls a lot on cheap Android GPUs.

1

u/EmreZen 2d ago

Good call on both. I already reuse Vector3/Matrix4 scratch objects in useFrame, and instancing helped a lot with draw calls: each coin used to be 3 meshes, now all the coins in a level take 2 draw calls.

On iOS the scene runs in a WebView, so it's JavaScriptCore there. On Android it's expo-gl on Hermes. It ran well on the cheap phones I tried, but I haven't looked at GC pauses specifically, so I'll check that before the Android launch. Thanks!

2

u/dawedev 1d ago

JSC on iOS and Hermes on Android is an interesting split, probably worth profiling each one on its own. Good luck with the Android launch.

2

u/LovesWorkin 2d ago

Why no android!?

1

u/EmreZen 2d ago

I'll spend a bit more time testing on Android. As you know, there are so many Android devices out there, and a significant number of them have pretty weak hardware. If you release your app without proper testing and it starts crashing, your ranking on Google Play takes a hit.

4

u/MobileXapps 2d ago

On cheap Android the things that usually hurt most with three.js-style rendering are texture memory and pixel ratio, more than JS. expo-gl uploads textures as full RGBA, so a few 2048 textures eat the GPU budget fast; KTX2/Basis compressed textures or simply halving sizes helps a lot. And cap the pixel ratio, many cheap phones report 2.75-3, rendering at 1.5-2 looks almost the same and costs far less.

The other one is heat. A game that holds 60 fps for two minutes can drop hard after ten when the phone throttles, so I'd run a 15 minute session with your FPS tool logging before calling Android ready, not just a quick run.

Launching on iPhone first makes sense, the Android device spread is the real work.

1

u/DulsKerty 1d ago

The 15 minute soak test is so true tbh, short dev runs completely hide the thermal throttling issue.

1

u/Jonovono 2d ago

I’ve been building one with rive and it’s a lot of fun. I started the skia / threejs route but had much more success with rive so far !

1

u/EmreZen 2d ago

I'll definitely give Rive a try. Thanks for the recommendation! 😊

2

u/Jonovono 2d ago

I've been seeing people use it on twitter, so I tried it out. Might not be appropriate for all use cases (it's not like a bevy replacement maybe?): This is one I saw: https://x.com/MattJedrzejewsk/status/2110388960644288569

1

u/EmreZen 2d ago

Awesome 😍

1

u/GeekyAntsBFSI 2d ago

Curious what made the biggest difference on cheaper Android phones. Was there one change that noticeably reduced stutter, or did it take a lot of small fixes? Would love to hear what your FPS overlay caught that wasn’t obvious during playtesting.

1

u/hanggoutapp 2d ago

I've worked with React Native CLI and Expo, mainly building mobile applications, and I'm interested in exploring 3D development as well.

I think combining Three.js with React Native is an interesting approach, but performance, memory management, GPU limitations, and compatibility across Android devices can be challenging.

I'm curious about how you handled rendering optimization and FPS monitoring. Did you use a custom native rendering layer, or were Three.js and React Native sufficient?

Also, have you considered releasing the Android version after further testing? It would be interesting to see how it performs across different Android devices.