reearth / resium

React components for 🌏 Cesium
https://resium.reearth.io
MIT License
704 stars 130 forks source link

StrictMode and Mui Dialog breaks Resium #618

Closed Kai-W closed 2 months ago

Kai-W commented 11 months ago

I have an app where Cesium/Resium is used to rendere 3DTilesets on an Openstreetmap in a MaterialUI Dialog. With React StrictMode enabled the first component doesn't get unmounted properly. https://codesandbox.io/p/sandbox/magical-christian-fqsxd6?file=%2Fsrc%2FApp.tsx%3A64%2C23

Inside the Dialog there are 2 instances of Cesium. First a broken one and below it is a second working Cesium instance image

Tested on Windows with Chrome, Edge and Firefox.

Wierdly this only happens inside a Mui Dialog. Without the Dialog component Resium unmounts as expected

Skippou commented 11 months ago

I've updated from resium@1.16.1 to resium@1.17.1 then I get a similar issue.

In strict mode, this occurs.

I'm not using MaterialUI Dialog but a custom tailwind component with an absolute div.

Kai-W commented 10 months ago

i tried to reproduce the problem without Material UI: It seems the problem occures if there is a change in the component hierarchy https://codesandbox.io/p/sandbox/trusting-ride-v7jqxz?file=%2Fsrc%2FApp.tsx%3A87%2C22

Kai-W commented 2 months ago

The new Resium Version seems to fix the duplication bug but moving the viewer to the bounding box works for the first render but breaks after a recreation of the viewer. https://codesandbox.io/p/devbox/elastic-thunder-wvx2n3?file=%2Fsrc%2FApp.tsx%3A20%2C

Kai-W commented 2 months ago

i opend a new issue https://github.com/reearth/resium/issues/661 for the new Problem. The duplciate Cesium render seems to be fixed