Only add static media once per bundle in the diff viewer.

Review Request #14545 — Created Aug. 1, 2025 and submitted — Latest diff uploaded

Information

Review Board
release-7.1.x

Reviewers

We're able to display certain binary files in our diff viewer. A binary
file is associated with a review UI, which renders the file. Some Review
UIs have static media bundles which get loaded onto the webpage.
Previously, we'd load these bundles unconditionally. However, now that
we use review UIs in the diff viewer, we've discovered that the static
media of a review UI gets loaded multiple times onto the page, depending
on how many instances of the review UI are in the diff viewer.

This lead to a problem with Power Pack's PDF and Office Document review
UIs in the diff viewer. The review UIs include a bundle for the pdf.js
module, which handles PDF rendering. This module sets up some global
state that is meant to facilitate rendering multiple PDF documents on
one page. However, since we were reloading the review UI's static
bundles everytime a new instance was added to the page, this global
state would get overwritten each time which would lead to PDF rendering
issues.

This change updates the diff viewer page to keep note of what static
bundles have already been loaded onto the page, and to skip loading any
existing bundles when rendering a new diff reviewable onto the diff
viewer. This ensures that any state from the static media of a review
UI will be shared between all instances of that review UI type on the
page. And we're avoiding unnecessary requests for loading the duplicate
static media.
  • Ran unit tests (no new failures).
  • Ran JS unit tests (no new failures).
  • Tested with multiple PDF and Office documents in the diff viewer,
    as well as non-binary files.
  • Tested changing the first and last commits in the diff viewer.
  • Tested with only non-binary files in the diff viewer.
  • Tested viewing standalone review UI pages.

Commits

Files