Skip to content

fix(core): eliminate 300ms click delay and fix runtime controller prop changes - #10422

Merged
chrisgervang merged 7 commits into
x/mjolnir-upfrom
chr/deckgl-controller-gesture-delays
Jul 10, 2026
Merged

chrisgervang merged 7 commits into
x/mjolnir-upfrom
chr/deckgl-controller-gesture-delays

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Jul 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes a bug where runtime changes to the controller prop via deck.setProps() had no effect (e.g., toggling doubleClickZoom at runtime)
  • Ensures the dblclick and dblclickdrag recognizers start disabled and are only activated by their respective controller options
  • Uses watch() (passive) for dblclick in Deck's picking registration so the picking system doesn't force-enable the recognizer
  • Adds dblclickdrag to click's requireFailure list so enabling double-click-drag zoom also correctly delays click
  • Adds a test/apps/gesture-timing interactive test app for measuring event handling delays
  • Documents the ~300ms click latency tradeoff when doubleClickZoom is enabled

Background

When doubleClickZoom is enabled (the default), the click recognizer has requireFailure: ['dblclick', 'dblclickdrag']. This causes mjolnir.js's TapRecognizer to defer click emission by ~300ms while waiting to see if a double-click follows. Setting doubleClickZoom: false disables the recognizer, causing hasRequireFailures() to skip it and allowing clicks to fire immediately.

Runtime controller prop bug (new fix)

Deck._getViews() was mutating the View instance's props.controller in-place. When ViewManager._diffViews compared old and new views, they were the same object (this === view → true in equals()), so it never triggered _rebuildViewports and controller.setProps() was never called. Fixed by cloning the view instead of mutating it.

Interaction with PR #9629 (onClick for double-click)

PR #9629 added dblclick: 'onClick' to EVENT_HANDLERS so that double-clicking fires the layer onClick callback with event.tapCount: 2. This only works when the dblclick recognizer is active (i.e., doubleClickZoom: true). Disabling doubleClickZoom gives instant clicks but loses onClick(tapCount=2).

See discussion in #10388 and the revert in #10420. Relates to #10384.

Changes

File Change
modules/core/src/lib/deck.ts Clone view in _getViews() instead of mutating; use watch() for dblclick picking
modules/core/src/lib/constants.ts Add enable: false to dblclick/dblclickdrag; add dblclickdrag to click's requireFailure; document ordering
modules/core/src/controllers/controller.ts Default doubleClickDragZoom = false (new feature, hasn't shipped)
docs/api-reference/core/controller.md Document latency tradeoff
test/interaction/map-controller.spec.ts Integration tests for dblclick zoom, click delay, and runtime prop propagation
test/apps/gesture-timing/ Interactive test app for measuring gesture delays

Test plan

  • All 13 integration tests pass (including runtime toggle regression test)
  • All 36 controller unit tests pass
  • All 542 core module tests pass
  • Runtime toggle regression test: red without fix, green with fix
  • Gesture timing test app demonstrates ~300ms vs ~0ms click delay
  • Double-click zoom works when explicitly enabled
  • RECOGNIZERS ordering confirmed: swapping causes runtime error

How to test the gesture-timing app

cd test/apps/gesture-timing && npm run start-local

Click the map and observe the event log. Toggle doubleClickZoom checkbox or use preset buttons to see click latency change in real-time. See test/apps/gesture-timing/README.md for details on reading the log.


Generated with Claude Code

@coveralls

coveralls commented Jul 4, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 83.139% — chr/deckgl-controller-gesture-delays into x/mjolnir-up. No base build found for x/mjolnir-up.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f567030. Configure here.

@chrisgervang
chrisgervang changed the base branch from master to x/mjolnir-up July 4, 2026 00:33
chrisgervang and others added 3 commits July 3, 2026 17:35
…k delay

The click recognizer's requireFailure dependency on dblclick causes
mjolnir.js to defer click events by 300ms. Disabling doubleClickZoom
by default removes this delay while keeping doubleClickDragZoom
available for zoom-by-drag gestures.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Same principle — once #10416 lands, dblclickdrag should be in click's
requireFailure list to prevent spurious clicks before a drag-zoom.
That would reintroduce the 300ms delay, so disable by default too.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Prevents spurious click events from firing before a double-click-drag
zoom gesture is recognized. Without this, a click would emit on the
first tap before the recognizer determines the user intends to drag.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@chrisgervang
chrisgervang force-pushed the chr/deckgl-controller-gesture-delays branch from f567030 to e250fc9 Compare July 4, 2026 00:37
Tests verify through the full EventManager → recognizer pipeline that:
- Click fires immediately when doubleClickZoom and doubleClickDragZoom
  are both disabled (the new default)
- Click is delayed ~300ms when doubleClickZoom is enabled
- Click is delayed ~300ms when doubleClickDragZoom is enabled

Also reorders RECOGNIZERS so dblclickdrag is registered before click,
which is required for click's requireFailure reference to resolve.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@chrisgervang
chrisgervang marked this pull request as draft July 4, 2026 01:04
…m is false

The dblclick/dblclickdrag recognizers start with enable:false so they don't
cause the 300ms click delay out of the box. Deck's picking system uses watch()
(passive) for the dblclick event so it doesn't force-enable the recognizer.
Only the controller's doubleClickZoom option enables it.

Also adds integration tests that verify click latency at the Deck level using
real pointer events dispatched to the canvas.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comment on lines +1090 to +1093
if (eventType === 'dblclick') {
// Use watch (passive) so the dblclick recognizer is only enabled by the
// controller's doubleClickZoom option — not by the picking system.
eventManager.watch(eventType, this._onEvent);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pessimistress while trying to unit test this, the LLM gathered some interesting context and proposed this change

The watch change at deck.ts:1090 is necessary to make doubleClickZoom: false actually eliminate the click delay.

The problem: Deck registers handlers for both click and dblclick events (for the onClick prop — it fires on both single and double clicks for picking). Using eventManager.on('dblclick', ...) enables the dblclick recognizer. The click recognizer has dblclick in its requireFailure list, so when dblclick is enabled, hasRequireFailures() returns true and the TapRecognizer adds a 300ms setTimeout before emitting click.

Even with controller: {doubleClickZoom: false}, the controller calls eventManager.off('dblclick', handler) — but the Deck-level on('dblclick', ...) handler still exists, keeping the recognizer enabled and the delay in place.

The fix: watch() registers a passive handler that still receives dblclick events (so onClick still fires on double-clicks when doubleClickZoom: true), but passive handlers don't count toward isEmpty() — so they don't force-enable the recognizer. Only the controller's on/off (driven by doubleClickZoom) controls whether the dblclick recognizer is active.

Without this change, the enable: false default on the dblclick recognizer gets immediately overridden by Deck's on('dblclick', ...) call, and the 300ms click delay persists regardless of the controller setting.

I'm still investigating and learning about this area of deck..

Comment thread test/interaction/map-controller.spec.ts Resolved
The dblclick tests were broken because page.mouse.dblclick() doesn't
properly target the canvas inside vitest's browser iframe. Fixed by
dispatching PointerEvents directly on the canvas element, matching how
mjolnir's PointerEventInput listener works (pointerdown on element,
pointerup on window). Each test uses a fresh Deck instance for isolation.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
if (eventType === 'dblclick') {
// Use watch (passive) so the dblclick recognizer is only enabled by the
// controller's doubleClickZoom option — not by the picking system.
eventManager.watch(eventType, this._onEvent);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context: on enables the recognizer, watch just passively watches already enabled recognizers.

This change is needed because without it in double click user's use case, if we disable double click zoom then double click also gets disabled. But that's not the expectation - the expectation is each event toggle is independent.

Deck._getViews() was mutating the View instance's props.controller in-place,
so ViewManager._diffViews short-circuited on identity (same object) and never
triggered _rebuildViewports. Controller option changes via setProps had no
effect at runtime. Fixed by cloning the view when applying the controller prop.

Also adds a gesture-timing test app that measures event handling delays and
demonstrates the ~300ms click latency tradeoff with doubleClickZoom.

- Restore doubleClickZoom=true default (breaking change avoidance)
- Add regression test for runtime controller prop propagation
- Add test/apps/gesture-timing for interactive delay measurement

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@chrisgervang
chrisgervang marked this pull request as ready for review July 9, 2026 20:57
@chrisgervang chrisgervang changed the title fix(core): disable doubleClickZoom by default to eliminate 300ms click delay fix(core): eliminate 300ms click delay and fix runtime controller prop changes Jul 10, 2026
@chrisgervang
chrisgervang merged commit 3555e8f into x/mjolnir-up Jul 10, 2026
5 checks passed
@chrisgervang
chrisgervang deleted the chr/deckgl-controller-gesture-delays branch July 10, 2026 17:32
chrisgervang added a commit that referenced this pull request Jul 10, 2026
* upgrade mjolnir.js

* fix(core): register dblclickdrag recognizer to recognize with click/dblclick (#10418)

Co-authored-by: Claude Opus 4.8 <[email protected]>

* fix(core): eliminate 300ms click delay and fix runtime controller prop changes (#10422)

* fix(core): disable doubleClickZoom by default to eliminate 300ms click delay

The click recognizer's requireFailure dependency on dblclick causes
mjolnir.js to defer click events by 300ms. Disabling doubleClickZoom
by default removes this delay while keeping doubleClickDragZoom
available for zoom-by-drag gestures.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(core): also disable doubleClickDragZoom by default

Same principle — once #10416 lands, dblclickdrag should be in click's
requireFailure list to prevent spurious clicks before a drag-zoom.
That would reintroduce the 300ms delay, so disable by default too.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(core): add dblclickdrag to click's requireFailure list

Prevents spurious click events from firing before a double-click-drag
zoom gesture is recognized. Without this, a click would emit on the
first tap before the recognizer determines the user intends to drag.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* test(core): add click delay unit tests for controller gesture config

Tests verify through the full EventManager → recognizer pipeline that:
- Click fires immediately when doubleClickZoom and doubleClickDragZoom
  are both disabled (the new default)
- Click is delayed ~300ms when doubleClickZoom is enabled
- Click is delayed ~300ms when doubleClickDragZoom is enabled

Also reorders RECOGNIZERS so dblclickdrag is registered before click,
which is required for click's requireFailure reference to resolve.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(core): ensure dblclick recognizer is disabled when doubleClickZoom is false

The dblclick/dblclickdrag recognizers start with enable:false so they don't
cause the 300ms click delay out of the box. Deck's picking system uses watch()
(passive) for the dblclick event so it doesn't force-enable the recognizer.
Only the controller's doubleClickZoom option enables it.

Also adds integration tests that verify click latency at the Deck level using
real pointer events dispatched to the canvas.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* test(core): fix dblclick integration tests using direct pointer dispatch

The dblclick tests were broken because page.mouse.dblclick() doesn't
properly target the canvas inside vitest's browser iframe. Fixed by
dispatching PointerEvents directly on the canvas element, matching how
mjolnir's PointerEventInput listener works (pointerdown on element,
pointerup on window). Each test uses a fresh Deck instance for isolation.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(core): propagate runtime controller prop changes to ViewManager

Deck._getViews() was mutating the View instance's props.controller in-place,
so ViewManager._diffViews short-circuited on identity (same object) and never
triggered _rebuildViewports. Controller option changes via setProps had no
effect at runtime. Fixed by cloning the view when applying the controller prop.

Also adds a gesture-timing test app that measures event handling delays and
demonstrates the ~300ms click latency tradeoff with doubleClickZoom.

- Restore doubleClickZoom=true default (breaking change avoidance)
- Add regression test for runtime controller prop propagation
- Add test/apps/gesture-timing for interactive delay measurement

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>

* docs(core): document onClick(tapCount=2) side-effect of doubleClickZoom

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Charles Richardson <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
Co-authored-by: Chris Gervang <[email protected]>
Co-authored-by: Chris Gervang <[email protected]>
@chrisgervang chrisgervang added this to the v9.3 patch releases milestone Jul 14, 2026
@chrisgervang chrisgervang mentioned this pull request Oct 7, 2026
12 tasks done
chrisgervang added a commit that referenced this pull request Oct 29, 2026
…kZoom is off (#10384) (#10973)

* fix(core): remove the 300ms click delay when doubleClickZoom is off (#10384)

Backport of the click-delay part of #10422 (merged into master via #10416)
to 9.3-release, without the DoubleClickDrag recognizer.

- The dblclick recognizer starts disabled, and Deck watches dblclick for
  picking, so only the controller's doubleClickZoom option enables it
- Clone the view when the controller prop changes so runtime changes apply
- Interaction tests; they read the protected eventManager field because
  Deck.getEventManager() isn't on 9.3

* fix(core): copy the views array before applying the controller prop

Cloning the first view wrote into the caller's views array, which throws
when the array is frozen.

* test(core): keep the frozen views array typed as View[]
@chrisgervang

Copy link
Copy Markdown
Collaborator Author

Released in deck.gl 9.3.12, as #10973 on 9.3.

@chrisgervang chrisgervang mentioned this pull request Nov 24, 2026
29 tasks
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