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

Expose CFRunLoopTimerCreate interval as setting for iOS #4074

Closed
Braymatter opened this issue Jan 4, 2025 · 11 comments
Closed

Expose CFRunLoopTimerCreate interval as setting for iOS #4074

Braymatter opened this issue Jan 4, 2025 · 11 comments
Labels
DS - ios S - enhancement Wouldn't this be the coolest?

Comments

@Braymatter
Copy link

Braymatter commented Jan 4, 2025

Description

Expose the EventLoopWaker interval as a configurable setting for the ios platform:

IOS Bevy apps are using a lot of CPU resources by default because this interval is so short. We've had positive impact on CPU/Energy use by lowering it to around 200hz instead of 1Mhz in a private fork. Ideally this setting would be exposed to client applications as realtime apps may have different polling requirements than input reactive apps etc.

image

Related to #3906, #3816

Relevant platforms

iOS

@Braymatter Braymatter added the S - enhancement Wouldn't this be the coolest? label Jan 4, 2025
@madsmtm
Copy link
Member

madsmtm commented Jan 4, 2025

Thanks for the suggestion! The timer is intended to be internal, and it's "just" a bug that it's triggering so frequently, so I'm not gonna expose a knob for tuning this (instead, we should fix the underlying bug).

@madsmtm madsmtm closed this as completed Jan 4, 2025
@madsmtm madsmtm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2025
@Braymatter
Copy link
Author

Braymatter commented Jan 4, 2025

The bug's been in limbo for some time -- Is there anything I can do to support getting the fix merged in?

@madsmtm
Copy link
Member

madsmtm commented Jan 4, 2025

I guess test #3906, but really what's needed is understanding of why the bug triggers in the first place

@VladasZ
Copy link

VladasZ commented Jan 7, 2025

Hi @madsmtm . So the only way to make it work properly today is to use a fork with different timer interval?

@madsmtm
Copy link
Member

madsmtm commented Jan 7, 2025

Until someone does the work to fix the bug properly, then yes. Which, realistically, will have to be me, but could technically be someone else.

@madsmtm
Copy link
Member

madsmtm commented Jan 7, 2025

My reasoning why I don't just merge #3906 and call it good is that I fear that it might break something else, and because I feel that's just not the way to do software development.

But writing that down, I guess iOS is very broken right now anyhow, so I retract my previous strong wording, I'm not that adamant about it. I'm still against changing a timer interval (that just masks the problem), but if you've really tested and think that my PR fixes it, then we can merge it without understanding of why it fixes it.

@extrawurst
Copy link

extrawurst commented Jan 7, 2025

@Braymatter and whoever else stumbles on this, there is capable workarounds to this timer: configure WinitSettings in Bevy. there is a post about this too.

@VladasZ
Copy link

VladasZ commented Jan 7, 2025

@madsmtm I tested patch from #3906 in my project and it definitely fixed my issue:

Before:
image

After:
image

I fear that it might break something else, and because I feel that's just not the way to do software development.

That is a good intention and I would agree with you in any other situation. But winit on iOS is currently unusable because of this bug and drains battery of mobile devices like crazy. In my opinion it is better to have at least some kind of fix for that than have no fix at all. If some other issues will happen because of this fix then somebody will create another issue and maybe it will help us understand this problem better.

@extrawurst
Copy link

@VladasZ is this using winit in the context of a bevy app?

@VladasZ
Copy link

VladasZ commented Jan 7, 2025

@extrawurst no it is my own project. You can see all the code in my issue: #3816 . The only dependency is winit.

@Braymatter
Copy link
Author

@extrawurst I appreciate you linking your blog post, we've also used WinitSettings successfully in our project. I think this Timer issue is maybe slightly different though. I still see differences in CPU profiling when I modify the timer frequency.

@madsmtm
I get your viewpoint about not wanting to expose the timer polling frequency, but given that iOS is (to everyone's point) functionally unusable without the fix I think it would be good to get it tested and merged rather than it's current limbo state.

I can try and pull your fix in and see if it causes any issues in our bevy app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DS - ios S - enhancement Wouldn't this be the coolest?
Development

No branches or pull requests

4 participants