Skip to content

fix(shared): remove Canvas image fallback - #2888

Open
quanruzhuoxiu wants to merge 3 commits into
mainfrom
agent/remove-canvas-image-fallback
Open

fix(shared): remove Canvas image fallback#2888
quanruzhuoxiu wants to merge 3 commits into
mainfrom
agent/remove-canvas-image-fallback

Conversation

@quanruzhuoxiu

@quanruzhuoxiu quanruzhuoxiu commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Remove the browser Canvas image-processing fallback and standardize browser and worker processing on Photon.
  • Keep Sharp as the Node.js backend, while allowing mixed browser/Node runtimes to fall back from Sharp to Photon.
  • Remove obsolete async compatibility branches that only existed for the Canvas implementation.
  • Isolate Photon module loading so browser and worker behavior can be tested deterministically.

Why

The previous implementation could produce a three-backend chain involving Sharp, Photon, and Canvas. Canvas also depends on DOM APIs, so it cannot provide a consistent fallback in worker environments. The image pipeline should have at most two native/WASM-backed implementations, with failures surfaced instead of silently switching to a third backend.

User impact

  • Browser and worker environments now use Photon consistently.
  • Photon initialization failures preserve their original cause.
  • Pure Node.js environments preserve Sharp failures instead of replacing them with a misleading Photon availability error.

Validation

  • pnpm --filter @midscene/shared test -- tests/unit-test/image/get-photon.test.ts tests/unit-test/image/index.test.ts tests/unit-test/transform.test.ts
  • npx nx build @midscene/shared
  • pnpm run lint
  • Verified that no Canvas fallback implementation or runtime references remain in the shared image pipeline.

@quanru
quanru marked this pull request as ready for review July 28, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants