Skip to content

macos: Support user-created wgpu surfaces. #124

@kunalarya

Description

@kunalarya

Currently, if a user creates a wgpu surface to attach to the editor window, the window will fail to free itself since it uses retainCount to approximate when the window is ready to be freed:

baseview/src/macos/view.rs

Lines 160 to 170 in b371263

// Hack for breaking circular references. We store the value of retainCount
// after build(), and then when retainCount drops back to that value, we
// drop the WindowState, hoping that any circular references it holds back
// to the NSView (e.g. wgpu surfaces) get released.
//
// This is definitely broken, since it can be thwarted by e.g. creating a
// wgpu surface at some point after build() (which will mean the NSView
// never gets dealloced) or dropping a wgpu surface at some point before
// drop() (which will mean the WindowState gets dropped early).
//
// TODO: Find a better solution for circular references.

I'd like to brainstorm ways to work around this. I don't fully grok the circular dependency issue yet, as I haven't repro'd it, so I want to keep that in mind.

@glowcoil do you happen to have an example of a circular dep, or hints towards how to reproduce the issue you saw?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions