# Lighting broken when loading the same tilesets in multiple viewers

**URL:** <https://community.cesium.com/t/lighting-broken-when-loading-the-same-tilesets-in-multiple-viewers/40841>\
**Category:** CesiumJS\
**Created:** [May 22, 2025, 9:18am UTC](https://community.cesium.com/t/lighting-broken-when-loading-the-same-tilesets-in-multiple-viewers/40841 "2025-05-22T09:18:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anneg](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/anneg/32/11217_2.png) [@anneg](https://community.cesium.com/u/anneg)\
**Post date:** [May 22, 2025, 9:18am UTC](https://community.cesium.com/t/lighting-broken-when-loading-the-same-tilesets-in-multiple-viewers/40841/1 "2025-05-22T09:18:32Z")

</div>

I created a [Sandcastle](https://sandcastle.cesium.com/#c=nVPvb9owEP1XLLRJQWpN7CQkAYo2tZWGtF+a0KRJ+VCTHGDNsZFtYKjif5/jAGVdh6p9ie27d+/dPTulksaiDYctaIJukIQtugXD1zX+7oNB0Sn9+VZJy7h0sKLTHRayPKukr6ukbWUhrd6hx0Ii1JJYLsCAbfTZlnF75GmX6G7a5vFcq3qi5HvjDpMqSJMojhrCZzz0/3kORmBTggS80rzmlm/AYFZVwbHNcyi9CKUNdI9KZsslCkBrpbtPgysBWKhF8HDfJJBQrOJycZxigN48+or9g2dpfHvy3I3oeSowlktmuZKD07hMW7djMvKT3sFCA5iggSN0ncY4JFlGopBmYUjj7KpNxCHu54TEURSlJM4oOcSdO37X9V+lObjbbPXOrvwD+Oa/cjfpNyXEC8qUYJpmaZ6lGc2jLEoOAtcu4S4gD5MkzFIa94/KIQ5T0s8Tkrt+8ywmyVkjIKupZtLMla5Pk39iVvNfMZ7c3X+eTqY/HHLvvPvzVktWg2bYWdy806BJdk8gehlUyM5VZ2TsTsC4bfIdr1dKW7TWIsC4Z6FeCebs783W5U/31kpjmsJR71g0qvgG8ermpf8KeZBLrZTh3mM2c89kbWGIrFoNwiHSfLG0gyR8O0QzZa2qm6CAuXVr0RmPeo7+kgp9lYonfCbSKv9D5fB4v2xAC7ZrIEsy/tgGMcajnjv+XWWVEjOmzxhbU38D).

In that sandcastle, I use 2 separate viewers, where I load the same Tilesets separately.  
I expected to see the same things in both viewers, but it seems that the lighting is broken in the first viewer.

I guess this is because Cesium re-uses the tileset, maybe from a cache? How can I tell Cesium to truly duplicate the resources?

 ![grafik](https://global.discourse-cdn.com/cesium/original/3X/b/9/b99e070af5b4f4b288210b8b13f9ce3dbcf1ae98.jpeg)

The console in Firefox prints this:

 ![grafik](https://global.discourse-cdn.com/cesium/original/3X/5/9/5952a64bd6834a6e76a70c77d6b960bb32a9ca81.png)

The console in Chrome prints this:

 ![grafik](https://global.discourse-cdn.com/cesium/original/3X/1/c/1cde8aa57cc1f34f044fc8cc7f93fded61ec9597.png)

This does not happen for simple entities:

> [@Sharing scene data between multiple viewers](https://community.cesium.com/t/sharing-scene-data-between-multiple-viewers/2257/7):
>
> Hi there, Creating an entity then adding it to multiple viewers works for me. See this code example: [http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=a12af66ed545a12d1bb83c02a4dad197](http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=a12af66ed545a12d1bb83c02a4dad197) Hope that helps, Rachel

Repaired link from above: [Cesium Sandcastle](https://sandcastle.cesium.com?src=Hello%20World.html&label=Showcases&gist=a12af66ed545a12d1bb83c02a4dad197)

Since I load both tilesets separately, I hoped that this is not “one datasource”.

> [@One datasource in two viewers / sharing datasources](https://community.cesium.com/t/one-datasource-in-two-viewers-sharing-datasources/14430/3):
>
> Hi there, Yes, you can duplicate anything into different viewers. However, there’s performance penalities for multiple viewers, as well as the fact that you have to duplicate (not share or reference) that data between them. A Cesium viewer is its own instance with its own engine and memory and JS stack and rendering. Depending on the complexity of a scene, it can get pretty crazy. Now, you can probably sync the view cameras in iteresting ways, but if there’s a lot of data it will get very slow…

---

<div class="post-metadata">

**Author:** ![jjhembd](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/jjhembd/32/10144_2.png) [@jjhembd](https://community.cesium.com/u/jjhembd)\
**Post date:** [May 24, 2025, 12:17am UTC](https://community.cesium.com/t/lighting-broken-when-loading-the-same-tilesets-in-multiple-viewers/40841/2 "2025-05-24T00:17:41Z")

</div>

Hi @anneg, I see the issue but I’m a little stuck on the cause. Perhaps it’s related to Sandcastle? Have you tried generating the two Viewers in a non-Sandcastle app?

I’ll try to come back to this next week.

---

<div class="post-metadata">

**Author:** ![anneg](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/anneg/32/11217_2.png) [@anneg](https://community.cesium.com/u/anneg)\
**Post date:** [May 26, 2025, 7:37am UTC](https://community.cesium.com/t/lighting-broken-when-loading-the-same-tilesets-in-multiple-viewers/40841/3 "2025-05-26T07:37:26Z")

</div>

Hi @jjhembd, thanks for your answer.

Yes, I found this issue initially in my own app which uses Cesium as a library. To make sure that this is not a problem in my app, I aimed to reproduce it in the sandcastle.

Fortunately, if the tilesets for the second viewer are loaded _way after_ the tilesets for the first viewer are loaded and added, [the lighting is not broken](https://sandcastle.cesium.com/#c=nVNra9swFP0rImxgQ6tIsl3bSRo22sICezHCYOAPVezbRMyWgqSkKyX/fbKUtOnWlTJ9sKT7OOfcq+taSWPRVsAtaIrOkYRbdAFGbDr83RujalD7+4WSlgvpwqpBPK5kfZTJXpfJQmYlrb5D95VEh4SwJZdz0YIBi2+06mZKvjfuMmuiPEvSJO7jEcJ2BTKKbIikMTqfBqh+7evApgYJeK1FJ6zYgsG8aR5Txodwd5uLDtTGRtFToP9RFtZTfczD7pv0oiwWP+ranaCUEHIw7PrDDtXc1isUgdZKx0Fq/waqBdyqZXR91TtQq3gj5BLtYUfozb3P2F17lL77jy/nns3jNGCskNwKJUcPlXNt3YnLxBd9CUsNYKIg6TRPMaFFQRPCCkJYWpwER0rwWUlpmiRJTtOC0b3dNcqfYv9VWoCbicB3NDgfwIv/Klyl31TbPsPMKGZ5kZdFXrAyKZJsT3DqHO4tSpJlpMhZenZgJpjk9KzMaOn0lkVKsyMhIJu55tLcKN09VP6JWy1+pXh2efV5Ppv/cJE717unw1XzDjTHrsX9tEe9M34IYi8HVXJwMpgYe9fCNIh8J7q10hZtdBthPLTQrVvu2j9cbOqfbuxqY/rEyfCQNGnEFonm/Lm/E/kg51orI3yP+cKNycbCGFm1HpEx0mK5sqOMvB2jhbJWdb2xhRvr9mownQwd/Ess7FUsHvAPksD8D5b98H7Zgm75XR+yotOPwYgxngzd9e8sq1S74PoIMTT1Nw). The webgl errors still remain, though, and they make me worry that something else might break in the short term. I would appreciate any help or tip to make sure the Framebuffer is complete.

---

<div class="post-metadata">

**Author:** ![anneg](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/anneg/32/11217_2.png) [@anneg](https://community.cesium.com/u/anneg)\
**Post date:** [July 24, 2025, 6:45am UTC](https://community.cesium.com/t/lighting-broken-when-loading-the-same-tilesets-in-multiple-viewers/40841/4 "2025-07-24T06:45:02Z")

</div>

Another user has the same issue, just error message is different. However, when I use their Sandcastle, I get the same error messages as mentioned here, so maybe different browsers produce different error messages?

> <https://github.com/CesiumGS/cesium/issues/12734>
>
> \### What happened?
> 
> When creating two independent \`Cesium.Viewer\` instances on t…he same page (each with its own container \`\<div\>\`), and loading a separate 3D Tileset into each viewer, the browser console throws the following WebGL error:
> WebGL context error when using two Viewer instances with 3D Tilesets: framebufferTexture2D INVALID\_OPERATION
> 
> 
> \### Reproduction steps
> 
> Create multi viewer in one page, then load their own tileset
> 
> \### Sandcastle example
> 
> https://sandcastle.cesium.com/#c=rZJdT8IwFIb/SrPEMBLsYCoxMIhGb7gnXu2mbAd2Yj+WtQPR8N/t2g3QRBOivVn7nq/nvBkHQ7YIO6hGZEYk7MgTaKwFfXFi2GuDvQH5SCVxx6AAjhImZM24hkGnM4mCGVSyDXj90J+m0l/b1v5z87xEDhoMXVdKLJR81PaxyMPb4f143KemABkan0Jm89P4lojqDCTQskKBBregKcvzrqD/PfldKbFU38JnaPzoQ/ybD/Gfffh/J+JLnIh/dCIYBIk2ew7zruIBRakqQ+qKh5RGBkTJmQEdrers1dJmWjc70TWHNw+Vo7Ype7u3laaNwjhu5DXaWj0hFtNA5fQd5qaYkNFweOXeBeCmMGdCqTR6D9lKK14bcPLBwyVRh5qsVL53yEmOW5JxpvUsDRqANDiu0h6XgrmNt/9FGhDXyCot0Z2d/4XGdkkiW3eacdYgvrRBg+7vSeTIPwE
> 
> \### Environment
> 
> Browser: Chrome 137.0.7151.122
> CesiumJS Version: 1.131
> Operating System: win 11

---

<div class="post-metadata">

**Author:** ![ryan\_veenstra](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ryan_veenstra/32/13711_2.png) [@ryan\_veenstra](https://community.cesium.com/u/ryan_veenstra)\
**Post date:** [October 16, 2025, 3:34am UTC](https://community.cesium.com/t/lighting-broken-when-loading-the-same-tilesets-in-multiple-viewers/40841/5 "2025-10-16T03:34:42Z")

</div>

Was there a resolution to this issue? I encountered it in a simple JS test app I’m writing.

Left is the first viewer, right is the second.

 ![image](https://global.discourse-cdn.com/cesium/original/3X/7/3/731142d73c56fd49ab03e9fd2a1467a9648bf30b.jpeg)

---

<div class="post-metadata">

**Author:** ![ryan\_veenstra](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ryan_veenstra/32/13711_2.png) [@ryan\_veenstra](https://community.cesium.com/u/ryan_veenstra)\
**Post date:** [October 16, 2025, 3:42am UTC](https://community.cesium.com/t/lighting-broken-when-loading-the-same-tilesets-in-multiple-viewers/40841/6 "2025-10-16T03:42:15Z")

</div>

There must be a race condition as this code has problems

```auto
    viewerA.scene.primitives.add(leftTileset);
    viewerB.scene.primitives.add(rightTileset);
    viewerA.zoomTo(leftTileset);
    viewerB.zoomTo(rightTileset);

```

Where this code is generally okay, though if the timeout is too small, sometimes both viewports will appear with darker lighting

```auto
    viewerA.scene.primitives.add(leftTileset);
    viewerA.zoomTo(leftTileset);
    
    setTimeout(() => {
        viewerB.scene.primitives.add(rightTileset);
        viewerB.zoomTo(rightTileset);
    }, 500);

```
