cocos / cocos-engine

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
https://www.cocos.com/en/creator
Other
8.56k stars 1.99k forks source link

使用小包模式后,出现 this._effect.getHash is not a function 的问题,集中在vivo的Y系列 #7567

Closed yuwanli closed 3 years ago

yuwanli commented 4 years ago

Creator version?(版本号)

v2.3.0

Affected platform?(受影响的平台)

Android vivo y系列(游戏暂时只有在vivo的快应用平台)

How to reproduce?(如何重现)

不能重现(能重现也不会来提issue了)

JavaScript output or error produced?(报错信息和调用栈)

java.lang.RuntimeException: (see stack)Uncaught TypeError: this._effect.getHash is not a function[0]getHash@/data/user/0/com.vivo.hybrid/app_resource/com.weibo.doudizhu.vivominigame/src/cocos2d-runtime.js:1
_checkBacth@/data/user/0/com.vivo.hybrid/app_resource/com.weibo.doudizhu.vivominigame/src/cocos2d-runtime.js:1
209.A._render@/data/user/0/com.vivo.hybrid/app_resource/com.weibo.doudizhu.vivominigame/src/cocos2d-runtime.js:1
209.A._children@/data/user/0/com.vivo.hybrid/app_resource/com.weibo.doudizhu.vivominigame/src/cocos2d-runtime.js:1
209.A._children@/data/user/0/com.vivo.hybrid/app_resource/com.weibo.doudizhu.vivominigame/src/cocos2d-runtime.js:1
209.T.visitRootNode@/data/user/0/com.vivo.hybrid/app_resource/com.weibo.doudizhu.vivominigame/src/cocos2d-runtime.js:1
209.T.render@/data/user/0/com.vivo.hybrid/app_resource/com.weibo.doudizhu.vivominigame/src/cocos2d-runtime.js:1
render@/data/user/0/com.vivo.hybrid/app_resource/com.weibo.doudizhu.vivominigame/src/cocos2d-runtime.js:1
mainLoop@/data/user/0/com.vivo.hybrid/app_resource/com.weibo.doudizhu.vivominigame/src/cocos2d-runtime.js:1
t@/data/user/0/com.vivo.hybrid/app_resource/com.weibo.doudizhu.vivominigame/src/cocos2d-runtime.js:1
t.processAnimationFrame.e@(no filename):8
e@(no filename):8

at com.vivo.hybrid.game.jsruntime.l.b(SourceFile:51)
at com.vivo.hybrid.game.jsruntime.l.a(SourceFile:41)
at com.vivo.hybrid.game.jsruntime.GameRuntime.javaScriptExceptionCallback(SourceFile:705)
at org.cocos2dx.lib.Cocos2dxRenderer.nativeRender(Native Method)
at com.vivo.hybrid.game.render.GameRender.onDrawFrame(SourceFile:152)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1577)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)

Demo project?(demo 项目)

无。

补充

我这边定位到源码,暂时先通过修改引擎代码,重新构建,来规避这个问题了。

getHash () {
        return this._manualHash || (this._effect && this._effect.getHash());
},

修改后:

getHash () {
        if (this._manualHash) {
            return this._manualHash
        }
        if (this._effect && this._effect.getHash && typeof this._effect.getHash === 'function'){
            return this._effect.getHash()
        }
},
xianyinchen commented 3 years ago

从报错信息看,应该是材质被destroy掉了,可能是资源被错误释放了,具体需要给个demo才能排查。