Gesture dispose() not called when exception thrown in handleUp(), causing workspace interaction to freeze ?

35 views
Skip to first unread message

CN Laster

unread,
Oct 16, 2025, 9:54:51 AMOct 16
to Blockly
Hello everyone, I have a question.

If an exception is thrown during the execution of Gesture.handleUp() before dispose() is called, the gesture will not be properly cleaned up.
This leaves the workspace in a broken state where all subsequent user interactions are blocked because the touch identifier remains set and event listeners are not unbound.


Current Code (core/gesture.ts:521-569)  


···
handleUp(e: PointerEvent) {
if (!this.isDragging()) {
this.handleTouchEnd(e);
}
if (!this.isMultiTouch() || this.isDragging()) {
if (!Touch.shouldHandleEvent(e)) {
return;
}
this.updateFromEvent(e);
Touch.longStop();
if (this.isEnding_) {
console.log("Trying to end a gesture recursively.");
return;
}
this.isEnding_ = true;
// PROBLEM: If any of these throw an exception, dispose() won't be called
if (this.dragger) {
this.dragger.onDragEnd(e, this.currentDragDeltaXY);
} else if (this.workspaceDragger) {
this.workspaceDragger.endDrag(this.currentDragDeltaXY);
} else if (this.isBubbleClick()) {
// ...
} // ... more conditionals
e.preventDefault();
e.stopPropagation();
this.dispose(); // ⚠️ Never reached if exception thrown above
} else {
e.preventDefault();
e.stopPropagation();
this.dispose(); // ⚠️ Never reached if exception thrown above
}
}
···



Christopher Allen

unread,
Oct 20, 2025, 12:17:42 PMOct 20
to blo...@googlegroups.com
Hello,

If an exception is thrown during the execution of Gesture.handleUp() before dispose() is called, the gesture will not be properly cleaned up.
This leaves the workspace in a broken state where all subsequent user interactions are blocked because the touch identifier remains set and event listeners are not unbound.

There might be two different issues here:
  1. Is there a bug in core Blockly that is causing such an exception to be thrown?  If so we'd appreciate it if you filed a bug report with enough details that we can reproduce it.
  2. Separately, it does seem like it might be a good idea to make handleUp more robust.  Would you be so kind as to file a separate issue noting the potential problem and requesting that we add a try / finally here—and/or send us a PR to do so yourself?

Best wishes,

Christopher

Reply all
Reply to author
Forward
0 new messages