# Sample code downloaded from Playground will result in an error

**URL:** <https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401>\
**Category:** Bugs\
**Created:** [December 7, 2020, 6:03pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401 "2020-12-07T18:03:58Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [December 7, 2020, 6:03pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/1 "2020-12-07T18:03:58Z")

</div>

I tried to download the sample code from Babylon.js Playground.  
However, I get an error when I try to do it.

The following is the reproduction procedure.

1. Goto Babylon.js Playground  
[https://playground.babylonjs.com/](https://playground.babylonjs.com/)
2. Download sample.zip  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/d/db07a932b7eb87fcf75b6b1972041cff4386d000.png)
3. Unzip sample.zip
4. Start a local server and access the sample URL.  
The following error occurs and the sample is not displayed.

```auto
Uncaught TypeError: Cannot read property 'runRenderLoop' of null

```

Probably because the `initFunction` is not called.

---

<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:** [December 7, 2020, 6:47pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/2 "2020-12-07T18:47:01Z")

</div>

Correct! I forgot to fix that

thanks a lot, I will make that work

---

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [December 7, 2020, 6:49pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/3 "2020-12-07T18:49:12Z")

</div>

BTW, it would be nice to be able to switch to WebGPU as well.

---

<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:** [December 7, 2020, 6:49pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/4 "2020-12-07T18:49:48Z")

</div>

You can already in the PG but I do not plan to support it in the downloadable one (yet)  
I mean: the downloadable version will use the same engine as the one active when you hit save

---

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [December 7, 2020, 6:56pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/5 "2020-12-07T18:56:08Z")

</div>

It’s not necessary to be able to download it, but it would be nice to be able to test it easily on Playground.

The following WebGPU documentation has a link to Playground.

> **[WebGPU Support | Babylon.js Documentation](https://doc.babylonjs.com/advanced_topics/webGPU)**
>
> Dive into understanding the full scope of support for WebGPU in Babylon.js.

---

<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:** [December 7, 2020, 7:02pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/6 "2020-12-07T19:02:12Z")

</div>

it is already working 🙂

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

Pinging @PirateJC for the doc update

---

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [December 7, 2020, 7:05pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/7 "2020-12-07T19:05:24Z")

</div>

Oops, just noticed it. Great job.

---

<div class="post-metadata">

**Author:** ![PirateJC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/piratejc/32/1003_2.png) [@PirateJC](https://forum.babylonjs.com/u/PirateJC)\
**Post date:** [December 7, 2020, 9:36pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/8 "2020-12-07T21:36:15Z")

</div>

Doc has been updated. Will go into the next PR within the next couple hours

---

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [December 7, 2020, 11:57pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/9 "2020-12-07T23:57:14Z")

</div>

Thank you for your quick fix. I have confirmed that the correct sample code can be downloaded for each mode of WebGPU / WebGL2.

WebGPU mode result:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/f/f4c3b31a91fda4d469c583493cd902a2eadc2a45.png)

WebGL2 mode result:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/5/52bbceafbd1360b3dad6eb8a5be49354e5d99931.png)

---

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [December 7, 2020, 11:59pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/10 "2020-12-07T23:59:50Z")

</div>

Sorry if this has already been addressed. I found another mistake.  
The following URLs seem to refer to an old library (Babylon.js v4.2.0-alpha.16 or 27)

```
https://playground.babylonjs.com/indexWebGPU.html
https://www.babylonjs.com/demos/webgpu/forestwebgpu
https://www.babylonjs.com/demos/webgpu/oneSphereWebGPU
https://www.babylonjs.com/demos/webgpu/oneHelmetWebGPU
https://www.babylonjs.com/demos/webgpu/tenThousandSpheresWebGPU
```

---

<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:** [December 8, 2020, 10:04pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/11 "2020-12-08T22:04:49Z")

</div>

cc @Evgeni_Popov

---

<div class="post-metadata">

**Author:** ![cx20](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cx20/32/46_2.png) [@cx20](https://forum.babylonjs.com/u/cx20)\
**Post date:** [December 8, 2020, 10:44pm UTC](https://forum.babylonjs.com/t/sample-code-downloaded-from-playground-will-result-in-an-error/16401/12 "2020-12-08T22:44:30Z")

</div>

Thank you for catching up. The last one is already posted in another thread.

> [@Some WebGPU samples refer to older versions of the engine](https://forum.babylonjs.com/t/some-webgpu-samples-refer-to-older-versions-of-the-engine/16429):
>
> The following URLs seem to refer to an old library (Babylon.js v4.2.0-alpha.16 or 27) https://playground.babylonjs.com/indexWebGPU.html https://www.babylonjs.com/demos/webgpu/forestwebgpu https://www.babylonjs.com/demos/webgpu/oneSphereWebGPU https://www.babylonjs.com/demos/webgpu/oneHelmetWebGPU https://www.babylonjs.com/demos/webgpu/tenThousandSpheresWebGPU Some of these samples are referenced from the WebGPU Wiki. [image]
