I got this error when testing cc.loader.release on Cocos Creator V1.4.1 and Chrome.
You can reproduce the error by calling cc.loader.getDependsRecursively followed by cc.loader.release on a prefab that you have loaded and instantiate dynamically.
You are probably releasing some textures which are still in use, then it will report this.
I assume the asset you are releasing depends on some texture / sprite frame which are shared with other assets or the scene it self. But the loader don’t know that, so it just release them for you, and during the rendering process, the renderer complain that it can’t find the texture.
The right way is to eliminate all shared assets from the dependencies, if you don’t know which ones are shared, maybe you should use a white list to release assets, don’t release anything you don’t know, and do not release their dependencies
Hello, it might have some relationship to animation that have textures in it. I have created a test project that able to reproduce the issue. Please have a look.
Indeed it’s related to the animation, your animation rely on single color sprite frame, so does the background in the scene.
When you release the prefab and all its dependencies, you release the single color sprite frame, which cause the background trigger the gl error.
The solution is to eliminate the single color texture / sprite frame.
The reason that it’s working on native is because native has a reference count system, it won’t release the gl texture unless nothing is using it. But on web, we can’t have the same system because JS doesn’t expose its destruction process, so we decide to delete gl texture when user release a texture asset, otherwise it could be a gpu memory leak.
Can we keep track of the reference count manually and add a check at the release process? It doesn’t make any sense to not share texture assets. Our projects have lots of texture and effects, most of our projects are not playable without releasing memory.
What we done on our projects is keeping track each resource reference count each time it is loaded and prevent it from being release unless the reference count is 0.