# Freeze on iOS Safari when removing meshes

**URL:** <https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671>\
**Category:** Bugs\
**Created:** [June 14, 2021, 4:41pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671 "2021-06-14T16:41:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSa](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@JSa](https://forum.babylonjs.com/u/JSa)\
**Post date:** [June 14, 2021, 4:41pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/1 "2021-06-14T16:41:35Z")

</div>

This example freezes on iOS iPhone 12 Safari right after the screen is touched and camera moves a bit:

[https://playground.babylonjs.com/#U2KKMK#150](https://playground.babylonjs.com/#U2KKMK#150)

I have been investigating on this bug for a week now in other setting and have to say this is rather mysterious! Hope someone would have some idea?

The code does not freeze if mesh is not removed or disposed (also it does not freeze on desktop). So, for some reason now there is a rather serious lockup situation on iOS when meshes are disposed nearby the rendering loop…

_Edit:_ Now for a while this worked ok and then after 20 minutes started occuring again like in the video below. 🤔

---

<div class="post-metadata">

**Author:** ![JSa](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@JSa](https://forum.babylonjs.com/u/JSa)\
**Post date:** [June 14, 2021, 4:43pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/2 "2021-06-14T16:43:12Z")

</div>

Here is a video of what happens:

[https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/b/1b530f215ba94339fccc0e987f5424064a7ebe75.mp4](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/b/1b530f215ba94339fccc0e987f5424064a7ebe75.mp4)

---

<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 14, 2021, 5:59pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/3 "2021-06-14T17:59:52Z")

</div>

Adding @Cedric

---

<div class="post-metadata">

**Author:** ![gabrieljbaker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gabrieljbaker/32/12670_2.png) [@gabrieljbaker](https://forum.babylonjs.com/u/gabrieljbaker)\
**Post date:** [June 14, 2021, 11:48pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/4 "2021-06-14T23:48:22Z")

</div>

Just reporting that we have noticed this issue too, in particular when we dispose a photodome on iPhone.

---

<div class="post-metadata">

**Author:** ![JSa](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@JSa](https://forum.babylonjs.com/u/JSa)\
**Post date:** [June 15, 2021, 6:43am UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/5 "2021-06-15T06:43:53Z")

</div>

Some more info:  
Bug seems to occur about 20% of times. It might occur a bit more if url is “added to homescreen” on iOS.

This bug also reminds me a lot of this bug, but that same fix does not fix this: [Extremely long freeze on iOS ( bare playground example ) - #19 by br-matt](https://forum.babylonjs.com/t/extremely-long-freeze-on-ios-bare-playground-example/21376/19)

---

<div class="post-metadata">

**Author:** ![JSa](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@JSa](https://forum.babylonjs.com/u/JSa)\
**Post date:** [June 15, 2021, 3:20pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/6 "2021-06-15T15:20:28Z")

</div>

_Some updates:_  
I am not running Babylon build with these modifications:

in freecamera.ts: line 243

```auto
    public attachControl(ignored?: any, noPreventDefault?: boolean): void {
        noPreventDefault = Tools.BackCompatCameraNoPreventDefault(arguments);
        //this.inputs.attachElement(noPreventDefault); // Comment out any input code
    }

```

in scene.ts: line 1482

```auto
        if (DomManagement.IsWindowObjectExist()) {
            //this.attachControl(); // Comment out any input code
        }

```

…and so far this seems to elimite the lockup. I am not sure yet though, as the bug reproduces at 20% propability anyways…

@gabrieljbaker: I am interested in knowing if the photodome lockup happens everytime? Could that make a good test case as Playground for this?

---

<div class="post-metadata">

**Author:** ![br-matt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/br-matt/32/22436_2.png) [@br-matt](https://forum.babylonjs.com/u/br-matt)\
**Post date:** [June 15, 2021, 6:07pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/7 "2021-06-15T18:07:58Z")

</div>

Sadly I got the freeze in my app again. It was later than used to happen, now that the other freeze is fixed.

Can confirm with @JSa playground in first post of this thread freezes me every time ( not 20% for me )

---

<div class="post-metadata">

**Author:** ![JSa](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@JSa](https://forum.babylonjs.com/u/JSa)\
**Post date:** [June 15, 2021, 7:47pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/8 "2021-06-15T19:47:16Z")

</div>

@br-matt : To be more accurate, it occurs this way for me:

- At times I can run the example like 4 hours trying every now and then =\> It works all the time, 0% reproduction rate.
- Then, next time I try =\> It freezes for on the first try and no matter what I do it keeps freezing every time! Even if browser is restarted etc.

I even tested if it was somehow linked to iOS’s night time screen mode but no luck there either. 🙂

Right now though, I am developing my app for 6 hours without freeze using the fix mentioned above… I really hope I have found a lead now.

---

<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 16, 2021, 12:44pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/9 "2021-06-16T12:44:43Z")

</div>

@PolygonalSun could you have a look and double check if there is anything obvious on this one ? as it sounds related to your previous fix or at least pretty close in behavior.

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [June 16, 2021, 9:16pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/10 "2021-06-16T21:16:23Z")

</div>

I’ll take a look at this and see what I can find.

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [June 17, 2021, 10:51pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/11 "2021-06-17T22:51:13Z")

</div>

Assigned @PolygonalSun on June 17, 2021, 10:51pm UTC



---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [June 23, 2021, 12:24am UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/12 "2021-06-23T00:24:34Z")

</div>

So I’ve been testing this on iPhone and I was unable to repro this currently (as of 5.0 alpha 28). I can keep trying every so often but I’m not sure what exactly this could be.

---

<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 23, 2021, 2:46pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/13 "2021-06-23T14:46:07Z")

</div>

I can not repro either, this is weird… ☹ hope somebody else can try it out ? @Cedric maybe ?

---

<div class="post-metadata">

**Author:** ![br-matt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/br-matt/32/22436_2.png) [@br-matt](https://forum.babylonjs.com/u/br-matt)\
**Post date:** [June 23, 2021, 3:33pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/14 "2021-06-23T15:33:34Z")

</div>

Its crazy, yesterday I could not get the freeze 30x in a row tries ( was going to ping this thread )

Today, **first try** on the original PG, frozen. Battery at 92%… iPhone 12 pro max  
edit: today can get the freeze nearly every attempt

@PolygonalSun as soon as it loads you should be swiping left and right quickly spinning the camera back and forth

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [June 23, 2021, 10:06pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/15 "2021-06-23T22:06:06Z")

</div>

I’m still not having any luck. I’ve tried to repro it a bunch of times but no luck. I’m working with an iPhone XR.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [June 24, 2021, 6:54pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/16 "2021-06-24T18:54:09Z")

</div>

I can repro with iPhone 7+

---

<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 24, 2021, 7:00pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/17 "2021-06-24T19:00:41Z")

</div>

you are our best hope Gary !!!

---

<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 24, 2021, 7:01pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/18 "2021-06-24T19:01:18Z")

</div>

or maybe @Cedric ???

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [June 24, 2021, 7:03pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/19 "2021-06-24T19:03:28Z")

</div>

Can you repro it reliably? If so, tell me your secret

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [June 24, 2021, 7:26pm UTC](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671/20 "2021-06-24T19:26:22Z")

</div>

Are you guys moving the camera? It doesn’t repro until the camera is moved.

[Next page](https://forum.babylonjs.com/t/freeze-on-ios-safari-when-removing-meshes/21671.md?page=2)
