Skip to content

Windows Reactor#4479

Merged
kennykerr merged 1 commit into
masterfrom
reactor
May 28, 2026
Merged

Windows Reactor#4479
kennykerr merged 1 commit into
masterfrom
reactor

Conversation

@kennykerr
Copy link
Copy Markdown
Collaborator

Windows Reactor is a UI library for Rust developers targeting WinUI 3 to deliver native, efficient Windows experiences.

Overview

windows-reactor brings a React-like component model to native Windows desktop apps:

  • Declarative UI, no macros — build UIs as pure functions of state using a builder DSL and tuple-based children
  • Function components — typed props, context propagation, and error boundaries
  • Hooksuse_state, use_reducer, use_effect, use_context, use_memo, use_callback, use_resource, and more
  • 55+ widgets — Button, TextBlock, NavigationView, Grid, and many more, plus virtualized lists (ListView, GridView, FlipView) with templated row rendering
  • Asyncuse_resource and use_mutation for background data loading
  • Theming — runtime light/dark switching with ThemeRef brush bindings
  • Accessibility — built-in automation property modifiers, keyboard accelerators, and tooltips
  • Small footprint — single ~3 MB binary, no runtime framework to deploy

Getting Started

Prerequisites

Creating a new app

  1. Add the dependency:

    [dependencies]
    windows-reactor = { git = "https://github.com/microsoft/windows-rs" }
  2. Write your app:

    use windows_reactor::*;
    
    fn main() -> Result<()> {
        App::new().title("sample").render(app)
    }
    
    fn app(cx: &mut RenderCx) -> impl Into<Element> {
        let (count, set_count) = cx.use_state(0);
        let click = move || set_count.call(count + 1);
    
        vstack((
            button("Click").on_click(click),
            text_block(format!("count = {count}"))
                .font_size(18.0)
                .bold(),
        ))
    }

Running the samples

cargo run -p gallery
image
cargo run --example solitaire
image
cargo run --example calculator
image

Performance

Compared to the equivalent C# Reactor gallery app (measured 2026-05-27):

Metric Rust C# (JIT) C# (PublishAOT)
Clean build time 11.0 s 23.9 s 50.8 s
Deploy size 3.34 MB 128 MB 163 MB
Time to first window 160 ms 465 ms 364 ms
Working set (after settle) 109.5 MB 162.6 MB 128.4 MB
Private memory 101.0 MB 121.0 MB 117.3 MB
CPU time (startup + settle) 594 ms 1,063 ms 906 ms
Reconcile time (4,900 cells @ 10%) 3.1 ms 27.0 ms 29.4 ms

Special Thanks

Thanks to Chris Anderson for kickstarting this project and convincing me to give WinUI another try. Chris is the brains behind Reactor for C#. And I couldn't have done this without Rafael Rivera whose knowledge of Windows internals and WinUI continues to impress.

This builds on a mountain of work in windows-rs to optimize code generation, build time, and ergonomics. Over the last few weeks alone, the bindgen pipeline gained method-level filtering and mixed allow/deny lists with vtable demotion so that windows-reactor can generate only the exact COM surface it needs — no dead vtable slots, no unused methods. Delegate code gen was minimized to emit void-returning handlers with direct S_OK returns, and event registration now accepts closures directly with a non-generic EventRevoker. Two new crates landed: windows-reference for zero-overhead IReference<T> boxing (used throughout the reactor for nullable property values) and windows-time for idiomatic TimeSpan/DateTime conversions. The metadata reader was simplified by merging TypeIndex and ItemIndex, and the tokenizer switched to the quote crate — both reducing bindgen build time. Even if you're not interested in UI development, the profiling that went into this project greatly improved the core windows-* crates as well.

@kennykerr kennykerr merged commit 65066a7 into master May 28, 2026
29 checks passed
@kennykerr kennykerr deleted the reactor branch May 28, 2026 19:02
@dongle-the-gadget
Copy link
Copy Markdown

dongle-the-gadget commented May 28, 2026

Looking at your benchmarks: The C# AOT numbers don't make sense to me (my non-trivial WinUI 3 AOT app for all three architectures take 6 minutes to build, and takes up ~50 MB of disk space). I think that the AOT version might have actually been self-contained rather than AOT compiled.

@SaverinOnRails
Copy link
Copy Markdown

Looking at your benchmarks: The C# AOT numbers don't make sense to me (my non-trivial WinUI 3 AOT app for all three architectures take 6 minutes to build, and takes up ~50 MB of disk space). I think that the AOT version might have actually been self-contained rather than AOT compiled.

Yh these stats are funny. Rust would out perform C# of course but not by this much.

@kennykerr
Copy link
Copy Markdown
Collaborator Author

There are some internal discussions about deployment size, now that I have created a table. Stay tuned. 🙃

The actual numbers aren't that important - what matters is they were all measured on the same (old) machine.

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