-
Notifications
You must be signed in to change notification settings - Fork 920
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
El2.0 ios #871
El2.0 ios #871
Conversation
trailing comma in CFRunLoopTimerCallback
…ibly extend the iOS backend to work have methods callable from more than just the main thread
Thank you! Shouldn't window not be https://www.objc.io/issues/2-concurrency/thread-safe-class-design/
EDIT: I see you just went through and annotated every function with |
@zegentzy I agree it shouldn't be Send+Sync. Currently the iOS backend impls Send+Sync, but asserts that every UIKit method is called from the main thread (unless I missed something!). This was done to maintain the same API on the iOS backend as other backends e.g. if a users code compiles on windows/linux/etc it should also compile on iOS. I would be in favor of removing the It's possible, the UIKit restrictions could be worked around with GCD/caching, but that might be fairly tricky to do correctly - tho the macos backend does do this. |
I'm not sure what GCD is, but when I skimmed through the macos backend, I didn't spot anything that was stopping it from accessing the Glutin already assumes users are not going to move the window across threads (with functions like If compiling on all platforms is a concern, maybe we could compromise by adding a
This way at least we don't have to go around asserting that every UIKit method is called from the main thread. |
I think the el2.0 macos implementation makes an attempt at thread safety whereas the current version does not. GCD refers to Grand Central Dispatch. The macos el2.0 implementation uses it here to dispatch state changes to the main thread. Additionally, it checks that window creation happens on the main thread here. I didn't thoroughly review the code to ensure it was used consistently/correctly, but on a first glance, the "getters" look like they would also need routing through GCD to be truly thread safe. Something like the |
@zegentzy Deref was indeed much cleaner/more scalable. Pushed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Hopefully we can get something like this done to the macos backend in an other PR.
Should we go ahead and merge this in @Osspial? Worst case scenario, a slightly-faulty iOS backend is better than none. |
Yep, this looks good! Thanks! |
* port ios winit el2.0 implementation to the new rust-windowing repo * unimplemented! => unreachable trailing comma in CFRunLoopTimerCallback * implement get_fullscreen * add iOS specific platform documentation. Add a TODO about how to possibly extend the iOS backend to work have methods callable from more than just the main thread * assert that window is only dropped from the main thread * assert_main_thread called from fewer places
* port ios winit el2.0 implementation to the new rust-windowing repo * unimplemented! => unreachable trailing comma in CFRunLoopTimerCallback * implement get_fullscreen * add iOS specific platform documentation. Add a TODO about how to possibly extend the iOS backend to work have methods callable from more than just the main thread * assert that window is only dropped from the main thread * assert_main_thread called from fewer places
Here's the EL2.0 implementation for iOS.
@Osspial Sorry for my absence, and thanks for your patience! I have other things I'd rather be spending time on at the moment. I'm not sure if it makes sense for me to still be the iOS backend maintainer, though I'll probably scroll through tickets infrequently.
iOS defaults to fullscreen windows if both
dimensions
andfullscreen
areNone
which is natural for that platform, but the default window size here annoyingly breaks this. Of course it's easy to workaround by callingwith_fullscreen(monitor)
. Perhaps the default window size should only be provided for desktops?Let me know if you have questions. Tested on several iOS devices with different dpis and idioms (ipad/iphone).