Skip to content

Automation mouse input panics a live app #38

Closed

Description

@Lugribossk

Driving a real app process with the automation API, any locator.click() kills the app with a native panic. Read-only commands or .press() against the same app all work fine, only clicking crashes.

thread 'gpuix-ui' panicked at zed\crates\gpui\src\app\entity_map.rs:142:36:
cannot update gpuix_native::renderer::GpuixView while it is already being updated
thread 'gpuix-ui' panicked at library\core\src\panicking.rs:225:5:
panic in a function that cannot unwind

The UI thread aborts, the automation client then gets AutomationError: The GPUI UI thread stopped during the GPUI UI command, and the next React commit fails with The GPUI UI thread is not running.

Activity

  1. jhomra21 commented on Sep 14, 2026

    @jhomra21
    Contributor

    I can reproduce this same GpuixView double-update panic on published @gpuix/[email protected] with a real foreground macOS mouse click, not only through the automation API.

    Repro path: a fresh external consumer using [email protected] + published @gpuix/[email protected] paints normally and hover works, but the first physical left click aborts with:

    cannot update gpuix_native::renderer::GpuixView while it is already being updated
    fatal runtime error: failed to initiate panic
    

    The re-entry is in GPUIX text-selection cleanup. register_drag_listeners runs on every left-button mouse-up and unconditionally calls on_drag_end. GpuixView::render() supplies an on_drag_end callback that immediately calls drag_end_view.update(app, ...), so an ordinary mouse-up can update the same root entity while GPUI is still dispatching the event with GpuixView leased.

    I tested a minimal patch against the exact 0.7.0 source commit a24b4a42eb516c7b940eb8d34ecebb077df623bd (and its pinned GPUI submodule), changing only:

    • packages/native/src/text/paint.rs: capture was_dragging before ending selection and only invoke on_drag_end when a real drag was active.
    • packages/native/src/renderer.rs: defer the real drag move/end GpuixView updates with App::defer(...), so the current GPUI effect cycle unwinds and the entity lease is returned before the root view is updated.

    Exact tested source change:

    diff --git a/packages/native/src/renderer.rs b/packages/native/src/renderer.rs
    --- a/packages/native/src/renderer.rs
    +++ b/packages/native/src/renderer.rs
    @@
                         self.selection.clone(),
                         move |position, app| {
    -                        drag_move_view
    -                            .update(app, |view, cx| view.on_selection_mouse_move(position, cx))
    -                            .ok();
    +                        let drag_move_view = drag_move_view.clone();
    +                        app.defer(move |app| {
    +                            drag_move_view
    +                                .update(app, |view, cx| view.on_selection_mouse_move(position, cx))
    +                                .ok();
    +                        });
                         },
                         move |app| {
    -                        drag_end_view
    -                            .update(app, |view, _cx| view.stop_selection_scroll())
    -                            .ok();
    +                        let drag_end_view = drag_end_view.clone();
    +                        app.defer(move |app| {
    +                            drag_end_view
    +                                .update(app, |view, _cx| view.stop_selection_scroll())
    +                                .ok();
    +                        });
                         },
                     ))
    diff --git a/packages/native/src/text/paint.rs b/packages/native/src/text/paint.rs
    --- a/packages/native/src/text/paint.rs
    +++ b/packages/native/src/text/paint.rs
    @@
             if phase != DispatchPhase::Bubble || event.button != MouseButton::Left {
                 return;
             }
             let mut selection = up_selection.lock();
    +        let was_dragging = selection.is_dragging();
             selection.cancel_pending();
             selection.end_active_drag();
             drop(selection);
    -        on_drag_end(cx);
    +        if was_dragging {
    +            on_drag_end(cx);
    +        }
         });
     }

    That exact patched native 0.7.0 compiled on ARM64 macOS and then passed foreground acceptance in a fresh packed consumer: immediate paint, hover, repeated +, -, number click, Reset, and text selection drag/release. No GpuixView already being updated panic or crash.

    This looks like the same ownership bug behind the automation crash, but it also affects physical AppKit input in 0.7.0.

  2. added a commit that references this issue on Sep 14, 2026
    89b6799
  3. jhomra21 commented on Sep 14, 2026

    @jhomra21
    Contributor

    Follow-up: @gpuix/[email protected] is now published, but the physical foreground re-entry path is still present in the 0.8.0 source (remorses/gpuix@8d3ec094387152558d05a5b37de3cfbfca5d2d0a).

    I re-ran the same ownership patch on that exact 0.8.0 source and validated it through a full downstream compatibility matrix plus a real foreground macOS consumer:

    • native 0.8.0 source built successfully
    • 35 test files / 167 tests passed downstream
    • Solid 1, Kobalte, Tailwind, DAW, and all builds passed
    • immediate paint, hover, repeated clicks, decrement, reset, and real text drag-selection/release all passed
    • no GpuixView already being updated panic, abort, or backtrace

    The native source diff remained exactly:

    • packages/native/src/renderer.rs
    • packages/native/src/text/paint.rs

    napi build did regenerate packages/native/index.d.ts in a different order on one local run, but restoring that generated declaration left only the two Rust source files above; there is no API/type change involved in the patch.

    The exact ownership change tested against 0.8.0 is:

    --- a/packages/native/src/renderer.rs
    +++ b/packages/native/src/renderer.rs
    @@
                         move |position, app| {
    -                        drag_move_view
    -                            .update(app, |view, cx| view.on_selection_mouse_move(position, cx))
    -                            .ok();
    +                        let drag_move_view = drag_move_view.clone();
    +                        app.defer(move |app| {
    +                            drag_move_view
    +                                .update(app, |view, cx| view.on_selection_mouse_move(position, cx))
    +                                .ok();
    +                        });
                         },
                         move |app| {
    -                        drag_end_view
    -                            .update(app, |view, _cx| view.stop_selection_scroll())
    -                            .ok();
    +                        let drag_end_view = drag_end_view.clone();
    +                        app.defer(move |app| {
    +                            drag_end_view
    +                                .update(app, |view, _cx| view.stop_selection_scroll())
    +                                .ok();
    +                        });
                         },
    --- a/packages/native/src/text/paint.rs
    +++ b/packages/native/src/text/paint.rs
    @@
             let mut selection = up_selection.lock();
    +        let was_dragging = selection.is_dragging();
             selection.cancel_pending();
             selection.end_active_drag();
             drop(selection);
    -        on_drag_end(cx);
    +        if was_dragging {
    +            on_drag_end(cx);
    +        }

    The first half prevents an ordinary click from performing drag-end root-view cleanup when no drag existed. The deferred updates keep actual selection-drag move/end work from trying to lease GpuixView while GPUI is still dispatching the physical event with that entity on the stack.

    So 0.8.0 fixes the automation-input panic path described in the release notes, but this separate physical text-selection mouse-up re-entry still needs this ownership fix (or an equivalent native fix) before downstream consumers can safely rely on the registry package for foreground clicks.

  4. added 2 commits that reference this issue on Sep 16, 2026
    dc2409a
    7ac9880
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions