Skip to content

It is a foot-gun that EventLoopProxy is !Sync on macOS #3448

@gretchenfrage

Description

@gretchenfrage

Hi all, thank you for your consideration. Someone previously created #3220 on this subject, but then closed their own issue when they found that there actually is an obstacle to making EventLoopProxy Sync on macOS. However, I'm creating this issue for further discussion because I think it is unfortunate that the API is as such.

EventLoopProxy being Sync only on non-macOS platforms makes it so that one can write code with winit that doesn't seem to be using any platform-specific features but nonetheless fails to compile on macOS while compiling fine on other platforms, which I think goes against winit's generally very nice goals and behaviors in terms of cross-platform abstraction.

Some possible ways I can imagine dealing with this include:

  • Make EventLoopProxy always !Sync
  • Make EventLoopProxy Sync on macOS by wrapping its internals in a mutex
  • Make EventLoopProxy always !Sync, but create a platform-specific SyncEventLoopProxy type which is like EventLoopProxy but Sync, and which EventLoopProxy can be converted into through a platform specific-API
  • Create a non-default feature flag which makes EventLoopProxy Sync and document that that feature flag can only be enabled on certain platforms

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions