Skip to content

Referencing Device in cache Map can cause errors when the app goes behind a Proxy #8107

@d0rianb

Description

@d0rianb

I encountered this issue when using a WebComponent that embeds a PlayCanvas application inside a Vue project.
The component instance is accessed through a Vue $ref, which is actually a Proxy object.
When I call a method that alter the rendering process on the component from outside (for example to add a gizmo), the application fails to retrieve the GraphicsDevice from the internal cache.
This happens because the Proxy changes the memory reference of the application object and all of its childrens, therefore the device lookup no longer matches the original cached reference.

if (!this._cache.has(device)) {
this._cache.set(device, onCreate());

It then try to call the onCreate argument, which is often undefined ex :
const library = programLibraryDeviceCache.get(device);

Possible fix : I think changing the DeviceCache map from Map<GraphicsDevice, any> to Map<string, any> using the device.canvas.id as key could solve this issue. Maybe it has side effect on AR/VR devices?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions