Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metal: check if in the main thread when calling create_surface #2736

Merged
merged 1 commit into from
Jun 7, 2022

Conversation

jinleili
Copy link
Contributor

@jinleili jinleili commented Jun 6, 2022

Connections
#2727

Description
On macOS and iOS platforms, calling UI APIs in non-ui thread will cause unexpected results. Tell the user exactly what the problem is by checking if it is in the main thread.

Also tried using Objective-C GCD to specify the main thread to execute the code, but view: *mut c_void is not a thread-safe object, and I don't think actively jumping threads is something wgpu should do.

Testing
Tested on macOS and iOS.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add documentation to create_surface and this function it will panic if not called on the main thread.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants