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

Failed to initialize WebGL context #23

Open
jhrmnn opened this issue Sep 28, 2015 · 7 comments
Open

Failed to initialize WebGL context #23

jhrmnn opened this issue Sep 28, 2015 · 7 comments

Comments

@jhrmnn
Copy link

jhrmnn commented Sep 28, 2015

I've noticed that in a notebook with many imolecule output cells, both Safari and Chrome fail to render all the cells, some of them throw the following error:

screen shot 2015-09-28 at 16 03 04

I've also noticed that when I develop a notebook and create a lot of imolecule output cells, the browser eventually starts throwing

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

I've found that this may be solved by keeping only a single renderer for different scene, but I don't know whether it would be possible to keep a single shared rendered for all imolecule outputs.

@patrickfuller
Copy link
Owner

The single renderer approach makes sense to me, and seems to be an easy upgrade if the renderer can change DOM elements.

Out of curiosity, how many instances do you have running when this occurs?

@jhrmnn
Copy link
Author

jhrmnn commented Sep 29, 2015

About 30, each with hundreds of atoms (not sure whether that matters). I was a bit surprised, didn't seem like a crazy number.

@patrickfuller
Copy link
Owner

After some testing, it looks like the renderer can't be shared across different canvases, ie. everything rendered has to be in the <canvas> div.

I'll leave the issue open in case another solution comes up, but won't be able to fix this any time soon.

@jhrmnn
Copy link
Author

jhrmnn commented Sep 30, 2015

Do you have an idea what refactoring would be needed? I might try doing it myself.

@patrickfuller
Copy link
Owner

In my testing, I made a global imoleculeRenderer variable, replaced this line with:

if (imoleculeRenderer === undefined) {
    imoleculeRenderer = new THREE.WebGLRenderer({antialias: true, alpha: true});

and then swapped out instances of this.renderer and self.renderer with imoleculeRenderer. This broke previous canvases, which makes sense.

Regarding whether or not there's a right way to do this, I honestly don't know. The one-renderer approach works if everything is on one canvas, but I don't think that's feasible in a notebook. Maybe there's a smart way to swap out active webGL canvases with static images?

@sxhexe
Copy link

sxhexe commented Sep 22, 2017

@Azag0 @patrickfuller Same problem here. Did you guys figure out any workarounds?

@patrickfuller
Copy link
Owner

Nothing straightforward unfortunately, at least within the constraints of the jupyter notebook.

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

3 participants