Too many active WebGL contexts (with XR)

Hi,
I’m using Playcanvas with 8thWall for an AR application. Recently I was introduced to the chrome dev tools (thank you yaustar!). I’m currently trying to polish out some final bugs and so I’ve turned to the console warnings to look for things I can fix. One which is troubling me is

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

I’ve looked at this forum post about it Too many active WebGL contexts but I don’t think I’m making new apps like this developer was. I am switching scenes though, and that seems to be where the problems occur. The structure for my app is 3 scenes, lets call them A, B and C. A goes to B. Then B can go to C. C can go back to B. The error usually happens when I’m going from C back to B, but occasionally it happens when B is going to C.

I’m not looking for an exact diagnosis here, I know it’s tough when I can’t share the project openly. Does this issue ring any bells? Is the warning something that comes up often but doesn’t actually matter? Next steps I should look into for figuring out what’s causing it?

Thanks for your help,
-Ezra

I’ve not seen that error from an Editor based project before :thinking:

Things I would consider to narrow down the issue:

  • Does removing the use of 8th Wall also stop the warning coming up?
  • Do you have an 8th Wall controller in each scene? If so, what happens if you only have it in the first scene (A)?
  • Is there something that gets initialised or created in scenes B and C?
  • Does it happen if you want from A -> B back to A and to B again?
1 Like

Thanks for the ideas!

  • Removing 8th wall does stop the warning
  • Removing the 8thwall controllers in B and C but putting one in A also stops the warning
  • There are lots of things that get instantiated in B and C, but at least my read on the situation is that they’re probably not causing it since the error goes away when I remove 8thwall but not anything else.
  • I do get the same error when I try oscillating between A and B instead of B and C

From going through all this it seems pretty clear to me that it’s an issue on the 8thwall side, and I’ll ask their devs. Wanted to follow up here first to see if you had any other ideas about what could be going on. Thanks!

1 Like

It sounds like the project is creating multiple 8th controllers instead of just one. Do you need to create one per scene?

1 Like

That is a good distinction to draw, if I put only the 1 xr controller in the first scene and delete it along with the first scene, then it’s fine (that’s what I tried and wrote up in the previous post). However, if I want the app to still work, then I have to keep the xrcontroller between scenes and still call stop and run on XR8. When I do this I get the same error as before, despite there only being on xrcontroller.

I hadn’t considered this distinction before though, maybe thinking about it this way will be fruitful for me.

In this case, I would use additive screen loading/unloading where you have a master scene with all the bits that need to be global/kept between scenes and load the other scenes in/out as children.

Here is a demo project: https://developer.playcanvas.com/en/tutorials/additive-loading-scenes/

1 Like

After all your advice I was able to narrow down the problem even more, now I know that it’s just from repeatedly stopping and starting XR, even with one xrcontroller (I did this in a scene by itself). Unfortunately since I use face effects and world tracking, and the only way to switch between them involves stopping and starting XR, I don’t think I’ll be able to fix the problem the way you suggest. I’m going to ask the 8thwall folks about what I can do, as I suspect it’s a bug on their end. Thank you for all your help!

1 Like