Skip to content

fix: guard videoPlayer.destroy() against re-entrant calls with jQuery UI 1.14.1#38062

Open
jignaciopm wants to merge 2 commits intoopenedx:masterfrom
eduNEXT:jipm/update-jquery-ui-version.2
Open

fix: guard videoPlayer.destroy() against re-entrant calls with jQuery UI 1.14.1#38062
jignaciopm wants to merge 2 commits intoopenedx:masterfrom
eduNEXT:jipm/update-jquery-ui-version.2

Conversation

@jignaciopm
Copy link
Contributor

@jignaciopm jignaciopm commented Feb 27, 2026

Description

jQuery UI upgrade: v1.10.0 → v1.14.1

This PR updates the local jQuery UI file (common/static/js/vendor/jquery-ui.min.js) from version 1.10.0 (2013) to version 1.14.1 (2024), the latest stable release from the official jQuery UI project, and updates the CDN reference in common/templates/xblock_v2/xblock_iframe.html accordingly.

Motivation:

  • Security & Maintainability: The previous version (1.10.0) is over a decade old and no longer receives fixes. Upgrading helps reduce technical debt and aligns with modern web standards.
  • Feature Consistency: The template common/templates/xblock_v2/xblock_iframe.html previously referenced jQuery UI 1.12.1 via CDN. This update ensures the CDN reference and the local vendor copy are in sync.
  • Modern browser support: jQuery UI 1.14.1 improves compatibility with modern browsers and drops legacy Internet Explorer-specific code.
  • Better behavior and fixes: Many UI components (e.g., Dialog, Tabs, Resizable) received bug fixes and accessibility improvements in versions 1.12–1.14.

Full changelog: https://jqueryui.com/changelog/ · Upgrade guide: https://jqueryui.com/upgrade-guide/1.14/


Fix: karma xmodule webpack tests failing after the upgrade

jQuery UI 1.14.1 includes a jquery-patch.js module that overrides $.cleanData to fire triggerHandler("remove") on any element that has a jQuery "remove" event handler registered — a behavior that did not exist in v1.10.0.

The video player registers state.videoPlayer.destroy as a "remove" handler on the video element:

player.on('remove', state.videoPlayer.destroy);

When any part of the teardown chain (fixture cleanup, slider destroy, volume slider destroy) calls $.fn.remove() or $.fn.empty(), the patched $.cleanData triggers videoPlayer.destroy() again — after delete this.videoPlayer had already run — causing TypeError: this.videoPlayer is undefined and cascading to 591 out of 619 karma tests failing.

Two defensive changes were made to 03_video_player.js:

  1. Guard against re-entrant calls — bail out immediately if this.videoPlayer is already gone.
  2. Eagerly remove the "remove" event handler — at the very start of destroy(), before any cleanup that could trigger $.cleanData.

Impacts: Developer only — no runtime behavior change for Learners or Course Authors.

Supporting information

Testing instructions

  1. Ensure Node.js 24 and Firefox are installed.
  2. From the repo root, run:
    nvm use 24
    npm install
    npm run build-dev
    npx karma start xmodule/js/karma_xmodule_webpack.conf.js --log-level debug --single-run --grep="Video"
  3. Verify that all 619 tests pass with 0 failures and 0 errors.

Deadline

None.

Other information

  • This change is purely defensive — it guards against a double-call scenario triggered by the jQuery UI upgrade. It does not alter any video player behavior in production.
  • The "remove" event handler cleanup added at the start of destroy() is safe: it mirrors the existing off('remove') call already present in HTML5Video.Player.destroy() (02_html5_video.js:235).

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Feb 27, 2026
@openedx-webhooks
Copy link

Thanks for the pull request, @jignaciopm!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@Gi-ron
Copy link

Gi-ron commented Feb 27, 2026

Hi @bradenmacdonald ,

We wanted to let you know that Luis Felipe wasn't able to continue working on the PR he opened for upgrading jQuery UI. However, we've picked up where he left off and added the necessary adjustments to make the Karma JS tests pass.

Thanks for your feedback and support!

@magajh magajh requested a review from bradenmacdonald March 2, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

4 participants