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

No render on iOS simulator #2546

Closed
MykhailoButkevych-MR opened this issue Sep 30, 2022 · 10 comments
Closed

No render on iOS simulator #2546

MykhailoButkevych-MR opened this issue Sep 30, 2022 · 10 comments
Labels
bug Something isn't working react-native to do with react-native

Comments

@MykhailoButkevych-MR
Copy link

MykhailoButkevych-MR commented Sep 30, 2022

There's an issue with rendering on iOS, no problem with Android though.
My setup: iPhone 12 Simulator, iOS 14.3, XCode 14, Intel cpu

Steps to reproduce:

  1. Project setup, script sequence:
npx create-expo-app
cd my-app
npx expo install expo-gl
npm install three @react-three/fiber
  1. Add this code into App.tsx:
import * as React from 'react'
import { SafeAreaView } from 'react-native'
import { useFrame, Canvas } from '@react-three/fiber'

function Box() {
  const box = React.useRef()
  useFrame(() => (box.current.rotation.x = box.current.rotation.y += 0.01))
  return (
    <mesh ref={box}>
      <boxGeometry args={[1, 1, 1]} />
      <meshPhysicalMaterial color="blue" />
    </mesh>
  )
}

export default function App() {
  return (
    <SafeAreaView style={{ flex: 1 }}>
      <Canvas>
        <ambientLight />
        <pointLight position={[-1, 1, 1]} castShadow />
        <Box />
      </Canvas>
    </SafeAreaView>
  )
}
  1. Run yarn ios

As a result there's just an empty white screen, no rotating blue cube.

@CodyJasonBennett CodyJasonBennett added bug Something isn't working react-native to do with react-native labels Sep 30, 2022
@krisidmisso
Copy link

@MykhailoButkevych-MR just had the same issue. Can confirm that it doesn't work on a simulator but it works on a real device.

@CodyJasonBennett CodyJasonBennett changed the title No render on iOS No render on iOS simulator Oct 8, 2022
@vinaciotm
Copy link

There's an issue with rendering on iOS, no problem with Android though. My setup: iPhone 12 Simulator, iOS 14.3, XCode 14, Intel cpu

Steps to reproduce:

  1. Project setup, script sequence:
npx create-expo-app
cd my-app
npx expo install expo-gl
npm install three @react-three/fiber
  1. Add this code into App.tsx:
import * as React from 'react'
import { SafeAreaView } from 'react-native'
import { useFrame, Canvas } from '@react-three/fiber'

function Box() {
  const box = React.useRef()
  useFrame(() => (box.current.rotation.x = box.current.rotation.y += 0.01))
  return (
    <mesh ref={box}>
      <boxGeometry args={[1, 1, 1]} />
      <meshPhysicalMaterial color="blue" />
    </mesh>
  )
}

export default function App() {
  return (
    <SafeAreaView style={{ flex: 1 }}>
      <Canvas>
        <ambientLight />
        <pointLight position={[-1, 1, 1]} castShadow />
        <Box />
      </Canvas>
    </SafeAreaView>
  )
}
  1. Run yarn ios

As a result there's just an empty white screen, no rotating blue cube.

this works on real device iphone 13 (results on spining blue cube on screen)

@an0tv
Copy link

an0tv commented Mar 4, 2023

Reproduced @MykhailoButkevych-MR code, ran it and experienced the same issue. However, I am not getting any sort of rendering on my iOS device when using expo go. My device is the iPhone 12 mini.

(Edit)
Turns out it was a problem with some of the dependencies and downgrading fixed the issue.

@hypekn1ght
Copy link

hypekn1ght commented Mar 8, 2023

I've been getting this too personally.

So just to clarify, is this the best pathway to rendering properly?:

eas dev build -> adhoc provisioning -> install eas build on real iOS device?

@CodyJasonBennett
Copy link
Member

This is an upstream issue with expo-gl and XCode. Unfortunately, OpenGL was deprecated on Apple platforms, so this won't work without a Metal adapter or better -- ANGLE/WebGPU.

@CodyJasonBennett CodyJasonBennett closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2023
@lucascassiano
Copy link

Then.. what should I do? Just test on iOS devices instead?

@darimuhittinhey
Copy link

darimuhittinhey commented Aug 13, 2023

This is an upstream issue with expo-gl and XCode. Unfortunately, OpenGL was deprecated on Apple platforms, so this won't work without a Metal adapter or better -- ANGLE/WebGPU.

Does this mean the library will not work on ios devices? @CodyJasonBennett

@CodyJasonBennett
Copy link
Member

Then.. what should I do? Just test on iOS devices instead?

Yes. I better explain why below.

Does this mean the library will not work on ios devices?

That's not what that means at all. XCode simulator will not push frames on OpenGL which is now deprecated on Apple platforms. Try on a real device if you can, otherwise, if this affects quality control I'd reconsider the use of this library (and by extension expo-gl) for the moment.

I've been working on moving everything to wgpu/Metal for several years now, but with the lack of support from react-native, I'm afraid there's not much one can do.

@jacopocolo
Copy link

This might be known already but I'll add a small trick I found: if you have a M1/M2/M3 Mac, you can build from XCode using "My Mac (Designed for iPhone)" as a target and the app will install on your Mac, open and render r3f properly.

It doesn't replace building and testing on device, of course. But it might be useful for testing and debugging — more useful than the simulator at least.

@CodyJasonBennett
Copy link
Member

I think we should be documenting this. It's unfortunate that Apple is deprecating OpenGL since it also affects web (Chrome desktop) atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working react-native to do with react-native
Projects
None yet
Development

No branches or pull requests

9 participants