galacean / engine

A typescript interactive engine, support 2D, 3D, animation, physics, built on WebGL and glTF.
https://galacean.antgroup.com/engine
MIT License
4.19k stars 299 forks source link

单页面应用刷新报错,WebGL: INVALID_OPERATION: bindTexture: object does not belong to this context #1063

Open chenlhuaf opened 2 years ago

chenlhuaf commented 2 years ago

Describe the bug 使用单页面应用时进行路由跳转后oasis组件报错,reload页面正常

To Reproduce Steps to reproduce the behavior:

  1. npm run dev
  2. 访问页面
  3. 修改代码
  4. 页面刷新,部分贴图和文字无法展示,相机组件无法操作

使用的版本 0.8.0-beta.3

image

chenlhuaf commented 2 years ago

{ "name": "vue-oasis", "version": "0.0.0", "scripts": { "dev": "vite", "build": "vue-tsc --noEmit --skipLibCheck && vite build", "serve": "vite preview" }, "dependencies": { "@oasis-engine-toolkit/controls": "0.8.0-beta.3", "@oasis-engine/baker": "1.3.0-beta.0", "@oasis-engine/lottie": "0.8.0", "@oasis-engine/physics-lite": "0.8.0-beta.3", "@oasis-engine/physics-physx": "0.8.0-beta.3", "@oasis-engine/spine": "0.2.1", "@tweenjs/tween.js": "18.6.4", "dat.gui": "0.7.7", "oasis-engine": "0.8.0-beta.3", "oasis-engine-toolkit": "0.8.0-beta.3", "vue": "^3.2.0" }, "devDependencies": { "@vitejs/plugin-vue": "^2.2.0", "typescript": "^4.1.3", "vite": "^2", "vue-tsc": "^0.29.8" } }

eyworldwide commented 2 years ago

我猜是路由切换的时候,包含 Canvas 的 vue 组件被销毁掉了,最好在切页面之前执行一下 engine.pause(),如果 Canvas 都销毁了,建议执行 engine.destroy(),这样可以避免内存泄漏。

gz65555 commented 2 years ago

建议先升级到最新的 beta 版本 0.8.0-beta.26,我们做了一下销毁的兜底

chenlhuaf commented 2 years ago

建议先升级到最新的 beta 版本 0.8.0-beta.26,我们做了一下销毁的兜底

好的,使用这个版本有所改善,但是同场景下,2D文字渲染还有有问题。

gz65555 commented 2 years ago

@chenlhuaf https://stackblitz.com/ 上创建一个复现项目给我们看下吧

chenlhuaf commented 2 years ago

@chenlhuaf https://stackblitz.com/ 上创建一个复现项目给我们看下吧

好的