cocos-engine
cocos-engine copied to clipboard
gfx object must call destroy, and should never be used again
Use Case
In webgpu backend, we have to destroy resources and delete object in xxx.destroy() method.
In native engine, v8 finalizer is used to delete native c++ object, while in webgpu, browser finalizer is not fully supported.
As a result, we must call destroy to delete webgpu object.
Problem Description
Currently, gfx object might be used after destroy.
const framebuffer = shadowFrameBufferMap.get("xxx");
frameBuffer.destroy();
frameBuffer.initialize(info);
It is forbidden in webgpu backend.
Proposed Solution
Remove all usages of re-initialization of gfx object.
How it works
No response
Alternatives Considered
destroy leak gfx object in webgpu backend.
Additional Information
No response
Does it affect native usage? In native, we just use IntrusivePtr to control the lifecycle.
I agree that should not reuse gfx objects when they are destroyed.
Does it affect native usage? In native, we just use IntrusivePtr to control the lifecycle.
It does not affect native usage. In native engine, v8's finalizer will be called and c++ object is deleted or decRefed. So there is no leak.
In webgpu, browser's finalizer might not be called or is not supported at all. So every webgpu/webasm object must be deleted manually.
@star-e I assigned @hana-alice , if it's not appropriate, please re-assign