Clean up detached views when changing revisions/commits in the diff viewer.

Review Request #14565 — Created Aug. 21, 2025 and updated — Latest diff uploaded

Information

Review Board
release-7.1.x

Reviewers

When we render binary file review UIs in the diff viewer, we receive an
HTML fragment from the server which we inject into the diff viewer. That
HTML includes JavaScript which creates the reviewable view and model objects
for the file.

When we change the revision or commits in the diff viewer, the HTML gets
removed from the DOM. However, any Backbone or other JS objects that were
created in that HTML fragment don’t actually get destroyed or cleaned up.
They end up holding unnecessary memory in the browser.

To address this, whenever we clear the diff viewer we emit a signal that
FileAttachmentReviewableViews will listen to and remove themselves.
Subclasses can override onRemove() to perform any additional cleanup
needed for their review UI.

  • Ran JS unit tests.
  • Used in a change where we clean up PDF and Office document review
    UIs in the diff viewer.
  • Tested changing the revision of a diff viewer that contains binary
    image files.

Commits

Files