[Engine] `pc.Application.destroy()` does not completely destroy the app instance

As mentioned above, I have a project that uses multiple apps. It is developed with engine and will eventually be embedded in the vue project. I called the pc.Application.destroy() method in the beforeDestroy() method of vue, and then set the created app instance to null, like the following:

export default {
    name: "myVueContext",
    displayName: "MyVueContext",
    extends: common,
    data(){
        return{
            layerName: "My Vue Context",
            type: "webgl",
        }
    },

    // Some Vue code here.
    ......

    beforeDestroy() {
        this.app.beforeDestroy();
        this.app = null;
    },

    // Some Vue code here.
    ......

}

When I start the program, I call the Vue method to create multiple playcanvas apps, everything is normal, but when I delete one of the apps, other apps cannot perform mouse and keyboard input and other operations (but the console will not output any errors Information); When I also deleted the last app, the following error popped up:

I am not sure what caused the problem, but I suspect that destroy did not completely destroy the control, it was only caused by the removal of the visibility of the control, because when I clicked on the error message to view the source code, I saw an error related The code is related to continuing to render the next frame of the playcanvas app:

image

image

When I tried to continue to print the application, I found that it could still be printed, so I wonder if it is necessary to add any code besides destroy to completely destroy the playcanvas app instance.

Seek help and advice here.

There is a static function pc.Application.getApplication() that might still have a static reference to the last created application instance?

and also this holds a reference to the application, try setting this to null as well as a test

but it seems that for reason the render next frame is getting called … perhaps it’s not getting cancelled / destroyed correctly as well.

A solution was found, but had to modify the engine. The problem occurred when the defaultMaterial under the Scene was deleted in advance for some unknown reason when the application was destroyed, resulting in the failure to execute the corresponding destroy() method, so add verification before calling. See this pullRequest for details:

1 Like