Closed alicjamusial closed 4 years ago
Hi, @alicjamusial , Do you mean you added multiple vc-viewers in one page? Then destroy one of them, causing Cesium to crash?
Hi, @alicjamusial , Do you mean you added multiple vc-viewers in one page? Then destroy one of them, causing Cesium to crash?
Yes, exactly.
How many vc-viewer did you add? I have time to test it.
Two is enough to cause the crash (you should see Cesium errors in the console after removing one of them).
Hello, I cannot reproduce the issue. Hello, This is an example of my test: vue-cesium-test.zip
Hello! Could you please change your main code to:
<template>
<div class="hello">
<div class="tool">
<button @click="DestroyViewer1">Destroy Viewer1</button>
<button @click="DestroyViewer2">Destroy Viewer2</button>
</div>
<vc-viewer v-if="view1" ref="viewer1"></vc-viewer>
<vc-viewer v-if="view2" ref="viewer2"></vc-viewer>
</div>
</template>
<script>
export default {
name: "HelloWorld",
props: {
msg: String
},
data() {
return {
view1: true,
view2: true
};
},
mounted() {
this.$refs.viewer1.createPromise.then(({ viewer }) => {
this.viewer1 = viewer;
});
this.$refs.viewer2.createPromise.then(({ viewer }) => {
this.viewer2 = viewer;
});
},
methods: {
DestroyViewer1() {
this.view1 = false;
},
DestroyViewer2() {
this.view2 = false;
}
}
};
</script>
In that scenario - after removing one of the viewer using button, the other crashes. Does it work for you now?
Well, if the v-if is used to destroy the vc-viewer, it will cause problems. Because the vc-viewer component will remove the CesiumJS loaded on the current page by default when it is destroyed.see: vc-viwer.vue
I thought that CesiumJS should be removed by default when destroying the vc-viewer. In your case, this may not be appropriate. Can I add a vue prop to let the user decide whether to remove CesiumJS when the vc-viewer is destroyed? Or do you have better suggestions?
Yeah, it's probably not appropiate in every case that requires many vc-viewer instances being displayed and hidden in application logic. Letting user decide via prop seems fair enough :)
Please use version 2.1.3, vc-viewer adds a removeCesiumScript prop to meet this demand.
Yay! Thank you :) Will test it today.
[BUG 反馈] Destroying one of many vc-viewer instances causes Cesium to crash
浏览器版本号
Firefox & Chrome
Vue 版本号
2.6.11
组件库版本号
2.1.0
现象描述
完整异常信息
在线示例 / 仓库 URL
I'll add later.
复现用例
预期输出
实际输出