# WebGL: invalid\_operation: useProgram on iOS (iPhone & iPad only)

**URL:** <https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733>\
**Category:** Bugs\
**Created:** [April 23, 2019, 8:16pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733 "2019-04-23T20:16:38Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [April 23, 2019, 8:16pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/1 "2019-04-23T20:16:38Z")

</div>

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

```auto
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](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/c/c43ac32c99afc362fa0bcc22f1dbf4d3b97ec36d.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 23, 2019, 9:35pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/2 "2019-04-23T21:35:12Z")

</div>

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

Pinging my Apple fanboy @sebavan 🙂

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [April 23, 2019, 9:48pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/3 "2019-04-23T21:48:00Z")

</div>

No idea either ☹

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [April 24, 2019, 1:06pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/4 "2019-04-24T13:06:31Z")

</div>

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](https://playground.babylonjs.com/#H1KP39) (maybe should bug)  
[https://playground.babylonjs.com/#H1KP39#1](https://playground.babylonjs.com/#H1KP39#1) (maybe shouldn’t bug)

Will try later when PG is fixed.

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [April 24, 2019, 1:26pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/5 "2019-04-24T13:26:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [April 24, 2019, 3:52pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/6 "2019-04-24T15:52:38Z")

</div>

Here is the texture  
 ![perlin_noise](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/3/35104db7f61b4075fd2fb8b00c4f1b329431f045.jpeg)  
And the parameters used on the bump

```auto
  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.

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [April 24, 2019, 3:55pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/7 "2019-04-24T15:55:40Z")

</div>

Yep, the texture seems totally OK.

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [April 24, 2019, 4:01pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/8 "2019-04-24T16:01:43Z")

</div>

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [June 13, 2019, 1:45pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/9 "2019-06-13T13:45:26Z")

</div>

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

Here is the PG  
[https://www.babylonjs-playground.com/#TH16ID#21](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](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.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [June 13, 2019, 3:32pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/10 "2019-06-13T15:32:33Z")

</div>

Pinging @sebavan to have a look

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 13, 2019, 3:43pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/11 "2019-06-13T15:43:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 13, 2019, 6:24pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/12 "2019-06-13T18:24:36Z")

</div>

ouch:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/b/ba51e960a87d921df5375b014a00db264d520e61.png)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 13, 2019, 7:00pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/13 "2019-06-13T19:00:43Z")

</div>

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

Should be fixed in a couple of hours

---

<div class="post-metadata">

**Author:** ![Gil\_Guminski](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gil_guminski/32/741_2.png) [@Gil\_Guminski](https://forum.babylonjs.com/u/Gil_Guminski)\
**Post date:** [June 13, 2019, 7:20pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/14 "2019-06-13T19:20:08Z")

</div>

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 !!!

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 13, 2019, 9:21pm UTC](https://forum.babylonjs.com/t/webgl-invalid-operation-useprogram-on-ios-iphone-ipad-only/2733/15 "2019-06-13T21:21:15Z")

</div>

It will be in the next nightly [Fix Glow/Shadow/Default material bones fallback by sebavan · Pull Request #6486 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/6486)
