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

native/macos: Re-re-implemented event loop #475

Merged
merged 1 commit into from
Aug 11, 2024

Conversation

birhburh
Copy link
Contributor

  • Reverted macos.rs to this implementation: Implemented blocking_event_loop for osx #443 (it's probably better compare changes with this PR than with latest commit to understand what was added additionally)
  • Now using own NSView with NSOpenGLContext instead of NSOpenGLView
  • For metal backend using redraw instead setNeedsDisplay, because somehow it reduces cpu usage (Cannot find info about enabling vsync like this in MTKView docs)
  • Fixed freezing on resize by drawing in draw_rect that called during "live resize"™. I don't like this approach, but it blocks main event loop while resizing, so it will not be some kind of concurency of opengl stuff i think
  • Reducing CPU usage when window is occluded
  • Added comments to hacky places, there are lots of them imo

Fixes:

- Reverted macos.rs to this implementation:
not-fl3#443 (it's probably better compare changes with this PR than with latest commit to understand what was added additionally)
- Now using own NSView with NSOpenGLContext instead of NSOpenGLView
- For metal backend using redraw instead setNeedsDisplay, because somehow it reduces cpu usage (Cannot find info about enabling vsync like this in MTKView docs)
- Fixed freezing on resize by drawing in draw_rect that called during "live resize"™. I don't like this approach, but it blocks main event loop while resizing, so it will not be some kind of concurency of opengl stuff i think
- Reducing CPU usage when window is occluded
- Added comments to hacky places, there are lots of them imo

Fixes:
- not-fl3#455
- not-fl3#470
@not-fl3
Copy link
Owner

not-fl3 commented Aug 11, 2024

Can't say that I understand a problem enough to have an opinion on the high-level approach, but reading through the code nothing strikes me wrong. I did not found excess of hacks, and with proper comments they did not really looked like too much of hacks anyway. Well, I guess it counts as a review.

In other words, great work, I trust your judgement here, @birhburh, lets merge it and will see whats up with bug reports!

@not-fl3 not-fl3 merged commit 30b4e17 into not-fl3:master Aug 11, 2024
10 checks passed
@brettchalupa
Copy link

I tested out this latest code on master on my Apple Silicon chip on macOS and it segfaults when running cargo run --release --example triangle. Possibly the same as this segfault on @birhburh's fork's prototype branch #470 (comment) but not 100% sure.

Happy to provide some more details or test things out. Let me know if a new issue is desired. 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.

3 participants