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

18 views
Skip to first unread message

CN Laster

unread,
Oct 16, 2025, 9:54:51 AM (2 days ago) Oct 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
}
}
···



Reply all
Reply to author
Forward
0 new messages