naver / egjs-view3d

Fast & customizable 3D model viewer for everyone
https://naver.github.io/egjs-view3d
MIT License
192 stars 27 forks source link

Failed to execute 'shaderSource' on 'WebGL2RenderingContext': parameter 1 is not of type 'WebGLShader'. #63

Open Akash952112 opened 1 year ago

Akash952112 commented 1 year ago

I am getting this error in my mobile device while rendering component.

Uncaught (in promise) TypeError: Failed to execute 'shaderSource' on 'WebGL2RenderingContext': parameter 1 is not of type 'WebGLShader'.

with this warning WARNING: Too many active WebGL contexts. Oldest context will be lost.

It works fine on my PC but gives this error on mobile devices.

previously I was using "@egjs/react-view3d": "^2.1.0", this version then I upgrade it to "@egjs/react-view3d": "^2.3.1" this latest version but it still gives an error

WoodNeck commented 1 year ago

Hello @Akash952112, Like the error message says, there's a limit to the maximum number of WebGL contexts that can be created. I'm wondering if the page you've created is beyond those limitations. I think the number was between 8 to 16 on mobile devices.

It's a browser restriction. so if you have too many components using WebGL on your page, try removing some.

Or, you can try showing View3D / or other WebGL components only when visible. This can be done with IntersectionObserver. You just have to call init when visible and destroy when not visible.

If you're using a single View3D instance only, then this is clearly a bug of View3D. In this case, please give me some hints(JS framework you're using, rendering code, etc...) to reproduce this issue and then I'll fix it.