perf(orbital_iced): throttle widget-tree rebuilds to 4 Hz #925

Merged
SakulFlee merged 1 commit from sakulflee/fix-909-iced-rebuild into main 2026-10-24 22:51:24 +00:00 AGit
Owner

Closes #909.

Rebuild Iced widget trees at most every 250 ms (4 Hz) instead of every frame, while still handling input every frame.

  • Default IcedState refresh interval to 250 ms and expose DEFAULT_REFRESH_INTERVAL.
  • Preserve dirty flags raised by messages or captured interactions until the next rebuild.
  • Skip update/layout/draw entirely for panels hidden by the world-driven visibility predicate, caching their widget state.
  • Remove the debug panels' 50 ms override and the unused DebugUiState refresh interval.

Verified with cargo fmt, cargo clippy -- -D warnings, and cargo test --no-fail-fast under the pinned 1.99.0 toolchain.

Closes #909. Rebuild Iced widget trees at most every 250 ms (4 Hz) instead of every frame, while still handling input every frame. - Default `IcedState` refresh interval to 250 ms and expose `DEFAULT_REFRESH_INTERVAL`. - Preserve dirty flags raised by messages or captured interactions until the next rebuild. - Skip update/layout/draw entirely for panels hidden by the world-driven visibility predicate, caching their widget state. - Remove the debug panels' 50 ms override and the unused `DebugUiState` refresh interval. Verified with `cargo fmt`, `cargo clippy -- -D warnings`, and `cargo test --no-fail-fast` under the pinned 1.99.0 toolchain.
perf(orbital_iced): throttle widget-tree rebuilds to 4 Hz
Some checks failed
Lint / lint (pull_request) Failing after 1s
PR / test (pull_request) Failing after 2s
00bd06921e
Panels previously rebuilt every frame by default, and the three debug panels at 20 Hz each. Re-run the view closure, widget diff and layout at most every 250 ms instead, while keeping input routing per frame.

Fix two correctness issues in the existing throttle: the dirty flag was cleared unconditionally at the end of process_events, so messages and captured interactions never forced the next frame to rebuild; and the world-driven visibility predicate was only checked while building, so hidden debug panels kept rebuilding and laying out.

Evaluate the visibility predicate before processing, cache the retained widget state when a panel hides, and check it again before drawing. Remove the debug panels' 50 ms override so they share the default, and drop the now-unused duplicate refresh interval from DebugUiState.
SakulFlee force-pushed sakulflee/fix-909-iced-rebuild from 00bd06921e
Some checks failed
Lint / lint (pull_request) Failing after 1s
PR / test (pull_request) Failing after 2s
to 3f7bc3e297
All checks were successful
Lint / lint (pull_request) Successful in 2m13s
PR / test (pull_request) Successful in 2m51s
2026-10-24 19:42:53 +00:00
Compare

Smart test results

Result: PASS

Scope: orbital_debug_ui, orbital_iced

Reason: directly changed crates

Elapsed: 2m 31s

Workflow run

Overall: 63 tests, 62 passed, 0 failed, 1 skipped

Nextest: 62 tests, 62 passed, 0 failed, 0 skipped
Doctests: 1 tests, 0 passed, 0 failed, 1 skipped

Outcome charts are split between nextest and doctests. The timing chart covers nextest only.

Crate Nextest Passed Failed Skipped Doctests Time
orbital_debug_ui 38 38 0 0 0/1 0.27s
orbital_iced 24 24 0 0 - 0.16s
pie showData
    title Nextest outcomes
    "Passed" : 62
pie showData
    title Doctest outcomes
    "Skipped" : 1
xychart-beta
    title "Slowest crates (nextest seconds)"
    x-axis ["orbital_debug_ui", "orbital_iced"]
    y-axis "Seconds" 0 --> 1
    bar [0.27, 0.16]
<!-- orbital-ci-test-results --> ## Smart test results **Result:** PASS **Scope:** orbital_debug_ui, orbital_iced **Reason:** directly changed crates **Elapsed:** 2m 31s [Workflow run](https://forgejo.sakul-flee.de/SakulFlee/Orbital/actions/runs/557) **Overall:** 63 tests, 62 passed, 0 failed, 1 skipped **Nextest:** 62 tests, 62 passed, 0 failed, 0 skipped **Doctests:** 1 tests, 0 passed, 0 failed, 1 skipped _Outcome charts are split between nextest and doctests. The timing chart covers nextest only._ | Crate | Nextest | Passed | Failed | Skipped | Doctests | Time | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | orbital_debug_ui | 38 | 38 | 0 | 0 | 0/1 | 0.27s | | orbital_iced | 24 | 24 | 0 | 0 | - | 0.16s | ```mermaid pie showData title Nextest outcomes "Passed" : 62 ``` ```mermaid pie showData title Doctest outcomes "Skipped" : 1 ``` ```mermaid xychart-beta title "Slowest crates (nextest seconds)" x-axis ["orbital_debug_ui", "orbital_iced"] y-axis "Seconds" 0 --> 1 bar [0.27, 0.16] ```
Sign in to join this conversation.
No description provided.