# Fun with CreateEnvTextureAsync

**URL:** <https://forum.babylonjs.com/t/fun-with-createenvtextureasync/28901>\
**Category:** Questions\
**Created:** [March 30, 2022, 8:11pm UTC](https://forum.babylonjs.com/t/fun-with-createenvtextureasync/28901 "2022-03-30T20:11:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [March 30, 2022, 8:11pm UTC](https://forum.babylonjs.com/t/fun-with-createenvtextureasync/28901/1 "2022-03-30T20:11:38Z")

</div>

I’m trying to resolve an issue raised, so I thought I would start with a PG. The PG itself seems to work once and then fail the second time:  
[create env texture | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#P3DTEZ#1)

Separately and I’ll need to figure this out on my own looks like - the codesandboxes crash as there is `no camera defined` - because that helper method is creating a “hostingScene” ( [Babylon.js/environmentTextureTools.ts · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/blob/fdbf393d1d7699dc7cc69cec1dca0819ebd2622a/packages/dev/core/src/Misc/environmentTextureTools.ts#L252)) and I try to render it 😄 I wonder if the “hostingScene” could be patched so that it’s “render” method was a no-op. I’ll see about that one as it’s technically a bug in `react-babylonjs` and I could be adding guard clauses - but I was hoping to avoid that as part of the defautl runRenderLoop, but I’m not expecting Scenes to be added at runtime that cannot be rendered (I render all Scenes for multi-canvas stuff):  
sandbox issue: [strange-sun-e824l5 - CodeSandbox](https://codesandbox.io/s/strange-sun-e824l5?file=/src/App.tsx)  
my version more declarative: [boring-fast-2nj6ls - CodeSandbox](https://codesandbox.io/s/boring-fast-2nj6ls)

Just wondering if anybody had a bright idea for that one.

---

<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:** [March 30, 2022, 8:16pm UTC](https://forum.babylonjs.com/t/fun-with-createenvtextureasync/28901/2 "2022-03-30T20:16:30Z")

</div>

I cannot get the PG to fail ☹

---

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [March 30, 2022, 8:20pm UTC](https://forum.babylonjs.com/t/fun-with-createenvtextureasync/28901/3 "2022-03-30T20:20:05Z")

</div>

Edge  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/f/5fa7f4ef3e959d2c06be45970654c593fbeb85c5.png)  
Firefox

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/8/d8b08b1fcf7bf74cd6ce3576c483f7e8a4f11c86.png)

I have a laptop RTX3060

---

<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:** [March 30, 2022, 8:29pm UTC](https://forum.babylonjs.com/t/fun-with-createenvtextureasync/28901/4 "2022-03-30T20:29:37Z")

</div>

woot! context lost is a massive issue (most often linked to memory overflow or bad driver issue)

cc @sebavan

---

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [March 30, 2022, 9:09pm UTC](https://forum.babylonjs.com/t/fun-with-createenvtextureasync/28901/5 "2022-03-30T21:09:27Z")

</div>

I don’t want to rule out a bad driver issue on my side - although I am not having other issues. If it’s working fine for others then certainly there is no need to investigate further! I thought maybe it was related to the host scene disposing (but that should not carry across PG replays), but have not investigated.

---

<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:** [March 30, 2022, 9:30pm UTC](https://forum.babylonjs.com/t/fun-with-createenvtextureasync/28901/6 "2022-03-30T21:30:12Z")

</div>

I can not repro either, but I d like to quickly rule out any leak possibilites ☹ I have checked and successfully launched more than 10 times the pg. Can you share how exactly you are able to repro ?

---

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [March 30, 2022, 11:36pm UTC](https://forum.babylonjs.com/t/fun-with-createenvtextureasync/28901/7 "2022-03-30T23:36:00Z")

</div>

I just click click the Run once or twice and it crashes.  
 ![context-lost](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/c/d/cd9cb6f7376dfbc3531b33338c8e73d411ceabd8.gif)

I’m going to mark as solved, since it looks like it’s just happening to me!
