Skip to content

racing: pinch must never die silently in AS plugin mode - #154

Merged
Grigory-Rylov merged 1 commit into
masterfrom
fix/pinch-plugin-mode
Nov 13, 2026
Merged

Grigory-Rylov merged 1 commit into
masterfrom
fix/pinch-plugin-mode

Conversation

@Grigory-Rylov

Copy link
Copy Markdown
Owner

Fixes the "pinch sometimes dead in Android Studio plugin mode until a ctrl+swipe revives it" bug.

Three compounding causes, all in the macOS pinch path:

  1. JNI monitor swallowed every magnify event, even when delivery failed (panel not yet in hierarchy, listeners empty, channel still compiling its dylib). Gesture eaten, no zoom.
  2. Echo timer armed on unconsumed gestures: the ctrl+wheel fallback (how macOS/JBR emulates pinch) was muted for 250ms even when our channels did nothing — so both paths were silent. A real ctrl+swipe is a plain wheel with no echo, which re-armed macOS emulation — hence "ctrl+swipe revives pinch".
  3. MRC leak: addLocalMonitorForEventsMatchingMask: returns an autoreleased object; without retain the monitor died on autorelease-pool drain. IntelliJ EDT drains the pool constantly, standalone AppKit runloop does not — that is why it was plugin-only and "sometimes".

Changes:

  • onMagnify now returns whether the gesture was consumed; the native monitor passes unconsumed events through to the regular dispatch (ctrl+wheel fallback).
  • lastMagnifyMs (echo muting) advances only on actual delivery, in both JNI and eawt channels.
  • monitor is retained for the process lifetime.
  • JNI descriptor (D)V → (D)Z.

Local gate green: :core:classes :app:classes :plugin:classes + :core:test --tests "...chart.racing.*".

JNI monitor swallowed every magnify event even when delivery failed
(panel not in hierarchy, listeners empty, channel mid-install) and the
echo timer was armed on un-consumed gestures, muting the ctrl+wheel
fallback — pinch looked dead until a real ctrl+swipe re-armed macOS
emulation. Now the monitor passes the event through when the JVM does
not consume it (onMagnify returns boolean), the echo timer moves only
on actual delivery, and the NSEvent monitor is retained (autoreleased
monitor died with pool drain inside IntelliJ EDT — the "sometimes").
@Grigory-Rylov
Grigory-Rylov merged commit b0854f3 into master Nov 13, 2026
11 of 13 checks passed
@Grigory-Rylov
Grigory-Rylov deleted the fix/pinch-plugin-mode branch November 13, 2026 18:38

This branch was previously deployed

1 inactive deployment
github-pages — 7d5c40f0 Deployed Nov 13, 2026 by Grigory-Rylov via deploy #51
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.

1 participant