Feature: don't cap bevy framerate when out of focus #52
Reference in New Issue
Block a user
Delete Branch "nondescriptpointer/feat/bevy-framerate-out-of-focus"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bevy's default behavior limits the framerate when the window is out of focus. Does not seem relevant for our use case, especially during debugging and profiling.
Summary by CodeRabbit
New Features
Refactor
📝 Walkthrough
Walkthrough
Compute an environment-aware flatscreenmode from CLI args or DISPLAY/WAYLAND_DISPLAY and, when true, register WinitPlugin (WakeUp, run_on_any_thread), add FlatscreenInputPlugin, and insert WinitSettings with focused/unfocused UpdateMode::Continuous; also extend imports for WinitSettings and UpdateMode.
Changes
src/main.rsSequence Diagram(s)
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
I pushed a fix in commit <commit_id>, please review it.Open a follow-up GitHub issue for this discussion.@coderabbitaiin a new review comment at the desired location with your query.@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type
@coderabbitai helpto get the list of available commands.Other keywords and placeholders
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed.@coderabbitai summaryto generate the high-level summary at a specific location in the PR description.@coderabbitaianywhere in the PR title to generate the title automatically.CodeRabbit Configuration File (
.coderabbit.yaml).coderabbit.yamlfile to the root of your repository.# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.jsonStatus, Documentation and Community
Actionable comments posted: 1
♻️ Duplicate comments (1)
🧹 Nitpick comments (1)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration.
📥 Commits
Reviewing files that changed from the base of the PR and between
877a32ab09andd1043f7b8c.📒 Files selected for processing (1)
src/main.rs(3 hunks)🔇 Additional comments (1)
💡 Verification agent
🧩 Analysis chain
Gating inconsistency:
flatscreenmodevsargs.flatscreencan enable Winit + flatscreen input while still choosing the XR pathYou compute
flatscreenmodefrom CLI args orDISPLAY/WAYLAND_DISPLAY, but later the XR/flatscreen branch still keys offargs.flatscreen(Lines 330–364). This can produce a mixed configuration:flatscreenmode == truedue to env vars,args.flatscreen == false.That risks running XR with a Winit event loop and flatscreen input enabled, which is likely unintended and could cause subtle event loop/input conflicts.
Action:
if !args.flatscreen { ... } else { ... }withif !flatscreenmode { ... } else { ... }, orargs.flatscreen.Additionally, please confirm that auto-enabling “flatscreen mode” based on env vars alone is desired behavior for your use case—this modifies previous semantics and broadens when flatscreen plugins are active, which goes beyond the PR objective of lifting the unfocused framerate cap.
Example (outside this hunk) for the branch below at Lines 330–364:
🏁 Script executed:
Length of output: 164
🏁 Script executed:
Length of output: 1559
Unify gating to use
flatscreenmodeYour code computes
flatscreenmode(fromargs.flatscreenor DISPLAY/WAYLAND env vars) but later gates the XR path on onlyargs.flatscreen. This allows Winit + FlatscreenInputPlugin to be enabled via env vars while still taking the XR branch, leading to mixed, likely unintended configurations.Please:
src/main.rsaround line 330, change:flatscreenmodevariable.DISPLAY/WAYLAND_DISPLAYis desired (this broadens plugin activation beyond the CLI flag).🤖 Prompt for AI Agents
@@ -378,6 +378,13 @@ fn bevy_loop(}),i don't think there's a reason to gate this behind flatscreen mode? i think it would be better to just insert that resource always
@@ -378,6 +378,13 @@ fn bevy_loop(}),If not in flatscreen mode bevy_oxr already inserts this resource:
https://github.com/awtterpip/bevy_oxr/blob/main/crates/bevy_openxr/src/openxr/init.rs
Actionable comments posted: 0
♻️ Duplicate comments (2)
🧹 Nitpick comments (2)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration.
📥 Commits
Reviewing files that changed from the base of the PR and between
d1043f7b8candfbf31e1df7.📒 Files selected for processing (1)
src/main.rs(3 hunks)🔇 Additional comments (1)
i am unsure if this is the behavior we actually want at all? i think unless we have an active OpenXR session we want to limit framerate based on the parent compositor? we don't really want an uncapped framerate since clients take a while to update and send back changes, granted flatscreen doesn't have proper event timings at all right now but i don't see a reason to waste resources
For me it is not really an issue for keeping the default "game" behavior except when profiling as the framerate is reduced when you are interacting with the profiler because the Stardust window goes out of focus. So perhaps we only set it to continuous when profile_tokio or profile_app has been enabled?
yeah seems reasonable, actually we can just always set it to max speed, we need to figure out how to do the timing ourself anyways since we need to do it instead of the xr wait ideally
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.