exokitxr / exokit

Native VR/AR/XR engine for JavaScript 🦖
MIT License
997 stars 117 forks source link

Aframe 0.9.2 crash #1296

Open extraymond opened 5 years ago

extraymond commented 5 years ago

Describe the bug

Aframe app won't load starting from version 0.9.2.

Error log

Error: Compositor error: VRCompositorError_TextureUsesUnsupportedFormat                                                                                                                                    [608/5809]
    at _submitFrame (/media/user/storages/git/exokit/src/index.js:1219:42)
    at Immediate._topRenderLoop (/media/extraymond/storages/git/exokit/src/index.js:1314:11)    

Downgrading to 0.9.0 works

To Reproduce Build demo app with aframe 0.9.2

System information:

avaer commented 5 years ago

What is the GPU in this repro?

extraymond commented 5 years ago

RX 480 with steamvr+padoka ppa: ppa

avaer commented 5 years ago

Thanks, I suspect that's the issue. Do you know what texture formats StreamVR supports with this driver setup?

extraymond commented 5 years ago

I'm not sure where to find that info, I will try it later.

Having tested both 0.9.0 0.9.1 0.9.2, this issue is started after 0.9.1, is there any way I can find the corresponding code path in aframe that caused this behavior?

I think it would be easier to bisect from their change logs.

Change log from 0.9.1 release

Things that seems to relate to texture or introduce major breakage would be:

  1. Use a fork of anime.js that has memory improvements from Kevin (#4028).
  2. Detaching entity from scene will preserve component data. Add Entity.destroy() method to clear components and return their memory to the pool (#4121).
avaer commented 5 years ago

Is there a reproduction case, or is this happening with anything that uses A-Frame?

It could be that some texture gets destroyed prematurely, or a resize at the wrong time messes up the framebuffer.

I would actually start with logging what's coming into the submit frame call -- Is it the first submit that fails? Or is something changing on VR entry, or a subsequent frame? Does this also happen in 2D mode (-x none)?

extraymond commented 5 years ago

Ah! I forget to add that, the app loads into 2D(app window), but would never go into VR. It's not crashing the whole thing, just not going into VR as it should. It might be something to do with what you said VR entry.

I tried the Hello world setup from aframe, still not working, it's safe to say that since such simple setup caught the bug, more complex scenes would be affected too.

<a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>

Blank scene with single entity not working either.

avaer commented 5 years ago

@extraymond Does -x webvr enter VR for your case?

extraymond commented 5 years ago

Sorry for the delay. Unfortunately adding -x webvr isn't working either.

avaer commented 5 years ago

At that point I would look into A-Frame and see why it isn't attempting to start the VR render loop.

extraymond commented 5 years ago

Hi! After Some testing, here's some additional info that might help. Version prior to 0.9.1 get this crash when trying to pre-load images in a-assets, it goes crashing without any external resources starting from 0.9.1.

Since in aframe, a-asstes are loaded via XHR request instead of fetch api, that might be a reason that caused this error.

If I preload assets using fetch api, and attach them to entities, the program works.

Another thing I noticed, is that comparing between -x none and -x webvr, when loading assets via fetch-api, webvr mode works while none mode will unable to load texture:

THREE.WebGLState: Error: WebGLRenderingContext::TexImage2D: invalid texture argument
    at Object.A [as texImage2D] (https://aframe.io/releases/0.9.0/aframe.min.js:98:26256)
    at M (https://aframe.io/releases/0.9.0/aframe.min.js:99:3348)
    at we.y [as setTexture2D] (https://aframe.io/releases/0.9.0/aframe.min.js:98:30577)
    at Re.setTexture2D (https://aframe.io/releases/0.9.0/aframe.min.js:100:9212)
    at Ft._t [as setValue] (https://aframe.io/releases/0.9.0/aframe.min.js:97:23927)
    at Function.Wt.upload (https://aframe.io/releases/0.9.0/aframe.min.js:109:8142)
    at M (https://aframe.io/releases/0.9.0/aframe.min.js:99:27748)
    at Re.renderBufferDirect (https://aframe.io/releases/0.9.0/aframe.min.js:100:6115)
    at x (https://aframe.io/releases/0.9.0/aframe.min.js:99:22431)
    at y (https://aframe.io/releases/0.9.0/aframe.min.js:99:22087)

But when loading assets via a-asstes instead of fetch-api, none mode works while webvr mode crashed with the same crash message that started this issue.

I was thinking that a potential root cause for this is that, when putting external media resources in a-assets, a-frame will try to get all resources with XHR request and receive them as text response, but if they are loaded via fetch-api, developers can use file reader and readAsDataUrl to convert blob into url object.

Aframe might be doing something different at first launch, that changes how assets are imported and rendered in the application, hence the crash when unexpected format is retrieved.