Repository navigation
Conversation
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Viewport disposal races can still cause feature-loading and mouse-interaction errors, while obsolete updates can overwrite current autoscale ranges.
4 open issues
What changed in this PR
This PR addresses listener leaks in igv.js when browsers, tracks, or viewports are removed, including the search-related leaks reported in #2122 and #2123.
Changes:
- Dispose replaced viewports and old session tracks, and correct listener removal.
- Replace internal drag-end listeners with a direct feature-track callback.
- Add disposal checks around asynchronous loading and popup handling.
| File | Description |
|---|---|
js/viewport.js |
Marks disposed viewports for asynchronous callers. |
js/trackViewport.js |
Guards loading and popup handling against disposal. |
js/trackView.js |
Disposes discarded viewports and fixes mouse-listener cleanup. |
js/feature/segTrack.js |
Removes an unused drag-end listener and flag. |
js/feature/featureTrack.js |
Replaces the drag-end listener with a repaint callback. |
js/browser.js |
Disposes session tracks, fixes keyboard cleanup, and invokes drag-end callbacks. |
Review effort: Balanced
Comment on lines
1588
to
1589
| const inViewFeatures = await Promise.all(trackViews.map(trackView => trackView.getInViewFeatures())) | ||
| const dataRange = doAutoscale(inViewFeatures.flat()) |
| if (this.disposed) return // Track was removed during load | ||
|
|
||
| // Viewports replaced during the load (a locus change, a closed multi-locus panel) have been disposed of | ||
| visibleViewports = visibleViewports.filter(viewport => !viewport.disposed) |
| disposeViewports() { | ||
| for (let viewport of this.viewports) { | ||
| viewport.viewportElement.remove() | ||
| viewport.dispose() |
| disposeViewports() { | ||
| for (let viewport of this.viewports) { | ||
| viewport.viewportElement.remove() | ||
| viewport.dispose() |
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #2122 and #2123, plus the similar leaks found by auditing the other listener registrations.
Reported issues
removeKeyboardHandleradds the keyup listener instead of removing it (removed browsers leak) #2122:removeKeyboardHandlercalledaddEventListenerinstead ofremoveEventListener, sodocumentkept every removed browser alive.RulerSweeperlisteners on the document and browser.TrackView.disposeViewports(wasremoveViewportsFromColumnContainer) now disposes them.Found in the audit
cleanHouseForSessionnow callstrackView.dispose().trackdragendhandler that was never removed. The listener is gone; the browser callstrack.trackDragEnd()when a pan ends.trackdragendhandler that set a flag nothing reads. Removed.removeTrackScrollMouseHandlersandremoveTrackDragMouseHandlerseach removed a handler under the wrong event or handler name, so the listener stayed.Disposal during async work
Disposing a viewport clears its properties, and a locus change or session load can now land while a load, a redraw or a pan is in progress.
Viewport.dispose()sets adisposedflag, and:TrackViewport.loadFeatures,IdeogramViewport.loadFeatures,handleTrackClick, the click-popup timer andTrackView.getInViewFeatures.TrackView.updateViewsand the group-autoscale pass ofBrowser.updateViewsstop if a viewport they were loading for was replaced. Otherwise they would autoscale without its features and apply the 0–100 default range over the new locus. Every path that replaces viewports (locus change, closing or selecting a multi-locus panel, session or genome load) ends with its own update, which runs against the new viewports.Browser.clearViewportInteraction()clears the drag state before viewports are disposed, since it refers to one of them.Behaviour change
trackDragEnd()applies to all feature tracks; the old listener skippedsnpandFusionJuncSpantracks, which now get one extra repaint when a pan ends.Testing
Checked in Chrome against the source, with BAM, BED, seg, and group- and self-autoscaled wig tracks, counting listeners on
document, the column container and the browser's event emitter:documentlisteners are gone afterremoveBrowser.Not done: heap measurements with forced GC, a regression test, and removing a group-autoscale track while its group is loading. The stale 0–100 range and the ideogram error were fixed from reading the code, not reproduced first. The related node tests pass; the full suite was last run after the first commit only (314 passing, 6 network timeouts).
🤖 Generated with Claude Code