Skip to content

perf(canvas-renderer): remove requestAnimationFrame polyfill/compat#2238

Merged
Thomaash merged 1 commit into
masterfrom
outdated-polyfill-removal
Jun 28, 2025
Merged

perf(canvas-renderer): remove requestAnimationFrame polyfill/compat#2238
Thomaash merged 1 commit into
masterfrom
outdated-polyfill-removal

Conversation

@Thomaash

@Thomaash Thomaash commented Jun 28, 2025

Copy link
Copy Markdown
Member

This served unsupported browsers (IE 9 era, no longer supported) and our test setup without proper polyfills for necessary browser APIs.

I mostly need to remove this because without it I can't merge all of the updates that are still pending across Vis.js repos. With updated dependencies it fails on maximum call stack size exceeded. Though it also cuts down on bundle size and reduces overhead.

This served unsupported browsers (IE 9 days and old JSDOM).
@Thomaash Thomaash requested a review from Copilot June 28, 2025 11:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes legacy requestAnimationFrame polyfills from the CanvasRenderer module and introduces a basic polyfill in the test setup to support JSDOM environments.

  • Remove internal rAF/timeout compatibility code from CanvasRenderer.js
  • Add temporary requestAnimationFrame/cancelAnimationFrame polyfill in tests
  • Clean up related timer properties and logic

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/canvas-mock.js Add basic rAF polyfill for JSDOM and note a TODO for a better solution
lib/network/modules/CanvasRenderer.js Strip out old timeout/rAF compatibility code and simplify rendering logic
Comments suppressed due to low confidence (3)

test/canvas-mock.js:158

  • [nitpick] The inline TODO is vague; consider creating a tracking issue for this enhancement and referencing its ID here, or remove the TODO once the solution is finalized.
  // TODO: JSDOM doesn't polyfill this. Find a better solution, maybe switch to

lib/network/modules/CanvasRenderer.js:16

  • [nitpick] The property name requestAnimationFrameRequestId is quite long; consider renaming it to a more concise identifier like frameRequestId or animationFrameId for readability.
    this.requestAnimationFrameRequestId = undefined;

lib/network/modules/CanvasRenderer.js:102

  • Consider adding unit tests for the new requestAnimationFrame-based rendering flow, covering _startRendering, _renderStep scheduling, and cancellation in the destroy handler.
  _startRendering() {

@Thomaash Thomaash merged commit 543cf06 into master Jun 28, 2025
7 checks passed
@Thomaash Thomaash deleted the outdated-polyfill-removal branch June 28, 2025 11:37
@vis-bot

vis-bot commented Jun 28, 2025

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 9.1.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants