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

Limit total time spent on green threads. #1774

Merged
merged 3 commits into from
May 30, 2024

Conversation

player-03
Copy link
Contributor

@player-03 player-03 commented Apr 2, 2024

Every single-threaded ThreadPool takes up a certain fraction of the app's time per frame. Without any coordination, they could take up more than 100% of available time, causing the app to slow down. By using static variables, we can make them work together to limit the total time spent per frame.

For instance, at 60 fps and a workLoad of 0.5, ThreadPools will work together to take up approximately 1/120 of a second each frame. This leaves another 1/120 for everything else on the main thread.

This also fixes a null pointer error by waiting to access Window.frameRate until a window is actually available.

Every single-threaded `ThreadPool` takes up a certain fraction of the app's time per frame. Without any coordination, they could take up more than 100% of available time, causing the app to slow down. By using static variables, we can make them work together to limit the total time spent per frame.
@player-03
Copy link
Contributor Author

@jgranick This PR should in theory fix the crash(es) you were seeing. Can you confirm?

@player-03 player-03 merged commit 57da678 into openfl:8.2.0-Dev May 30, 2024
26 checks passed
@player-03 player-03 deleted the ThreadPool_workLoad branch May 30, 2024 01:15
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.

None yet

1 participant