WebGL: invalid_operation: useProgram on iOS (iPhone & iPad only)

Hello everyone,

I’m currently facing a freeze on iOS only with Safari.

I’m updating the visibility of a few meshes with this code

this.scene.getMeshesByTags(mode).forEach(function (mesh, id) {
      mesh.visibility = 1
})`

I have 47 meshes with one specific tag.
Once the loop is done, it crashes.

Here is a printscreen to show the error
20

Tomorrow I will try to narrow the error to see if I can reproduce it in a PG.
Maybe the picture can already give you a hint of what could be wrong.

I tried some simple tests but I was not able to repro
https://www.babylonjs-playground.com/#SWAWU1

Pinging my Apple fanboy @sebavan :slight_smile:

1 Like

No idea either :frowning:

1 Like

Thanks for taking a look !

I did some research.

I found that displaying one specific mesh would make it crash.
The mesh is using the same material as some other meshes. But the material on this mesh makes it bug.
I cloned the material and did had the same issue.

I tested setting the bumpTexture to null (previously I had a map) and then it works.
So for now I disabled the bumpTexture on that mesh.

I wanted to try to reproduce it with playground but I can’t load it on iOS.
It needs split.js.map & jquery.min.map which are referenced. Withtout it the pg waits forever.

I keep the pg url I worked on here for backup
Babylon.js Playground (maybe should bug)
https://playground.babylonjs.com/#H1KP39#1 (maybe shouldn’t bug)

Will try later when PG is fixed.

How the texture looks like (is it power of 2 for example)?

Here is the texture
perlin_noise
And the parameters used on the bump

  HandInsideMat.bumpTexture.uScale = 100.0
  HandInsideMat.bumpTexture.vScale = 100.0

I don’t think this is the real source of the issue as it works well on other meshes with the same material.

Yep, the texture seems totally OK.

1 Like

Thanks :slight_smile:

Alright, I think I was finally able to reproduce it.

Here is the PG
https://www.babylonjs-playground.com/#TH16ID#21

With all the tests I made I think the glow layer is causing the main problem.
Strangely the scene showcasing the GlowLayer is working fine (https://www.babylonjs-playground.com/#LRFB2D#1).

In my app, disabling the glow layer or not having an emissive material make it work again.
What is strange is that it only occurs with some meshes.
I have no issue with Hand_Skin but with other it can crash quickly.

I hope you can see it and try to solve it now.
Let me know if I can help further.

Pinging @sebavan to have a look

I can repro i ll try to have it fix by end of day

1 Like

ouch:
image

@Gil_Guminski your repro helped a lot, we know exactly the culprit :slight_smile:

Should be fixed in a couple of hours

1 Like

I’m so happy to read this !
All in all, I have passed like around 3 days trying to see where it’s coming from.

The hardest part was that the bug wasn’t present all the time (and I don’t have an iOS device to always test and I don’t have a Mac to get the console :p).
I have some parts of the application working with a lot of meshes and glow. It was never an issue.
Today I just tried everything I could think of.

Thanks for the fix !!!

It will be in the next nightly Fix Glow/Shadow/Default material bones fallback by sebavan · Pull Request #6486 · BabylonJS/Babylon.js · GitHub

1 Like