Skip to content

Safari support - #17

Merged
pathanin merged 6 commits into
masterfrom
safari-support
Oct 18, 2026
Merged

pathanin merged 6 commits into
masterfrom
safari-support

Conversation

@pathanin

Copy link
Copy Markdown
Owner

Makes the editor work in Safari. All suites now also run in Safari's engine (Playwright WebKit, `BROWSER=webkit`).

Safari fixes

  • Text box: focus leaves it when it's committed. Safari kept focus on the hidden box, which swallowed the letter shortcuts.
  • Toolbar clicks while typing: a button click keeps the text open (Safari doesn't focus clicked buttons). A click on toolbar background still commits it.
  • Backspace on a focused button no longer navigates Back.
  • Trackpad pinch: Safari's `gesture*` events zoom the image, not the page. ctrl+wheel during a gesture is ignored.
  • Saving: a `.webp` saves as a PNG copy where there's no WebP encoder (Safari).
  • Slow saves: after a download-path save that took over 1 s, the toast offers Download again, since Safari may block a late download.
  • Text box sizing: a fallback where `field-sizing` is missing (Safari < 26.2).
  • Big repaints: the GPU fence turns itself off when its 1 px upload blocks (about 125 ms per big repaint in WebKit).
  • Large pastes: Safari has no `requestIdleCallback`, so idle reads now run in 8 ms slices.
  • Canvas size cap: `canvasFits()` refuses sizes past the browser's per-canvas cap (iPadOS 8192²) instead of opening a blank picture.
  • Small fixes: the Resize dialog anchor row layout, an apple-touch-icon, and an esbuild target of `safari16.4`.

Tests

  • `test/e2e/browser.js`: `BROWSER=webkit` runs smoke, history, preview, filledge, objects, alpha, libs and shots. A few checks allow for WebKit's whole-pixel mouse input, its `premultiplyAlpha:'none'` decode bug, and its native TIFF decoding. The Chrome checks are exactly as strict as before.
  • New checks: pinch, focus after commit, toolbar clicks while typing, Backspace, download bytes match the extension, Download again, the sizing fallback, `canvasFits`.
  • Results (local): all pass in Chrome (smoke 313) and WebKit (smoke 312).
  • `test/e2e/safari.js`: drives real Safari through safaridriver. It hasn't connected yet, so it's unverified.
  • How to test in Safari: see the README section "Testing in Safari".

Not verified

  • Real Safari: pinch, clipboard to other apps, download prompts, feel at 10000². The checklist is in the README.

🤖 Generated with Claude Code

pathanin and others added 6 commits October 18, 2026 18:49
…allback, text box sizing

- test/e2e/browser.js: BROWSER=webkit runs smoke, history, preview, filledge, objects, alpha, libs
  and shots in Playwright's WebKit; tests allow for its whole-CSS-px mouse input and its
  premultiplyAlpha:'none' decode bug, and expect native TIFF decoding there
- Text box: blur before hiding (Safari keeps focus on hidden elements, which swallowed shortcuts);
  a toolbar button click no longer commits the text (Safari doesn't focus buttons on click)
- Backspace/Delete: preventDefault before the focus check (WebKit can map Backspace to Back)
- Pinch: Safari gesture events zoom the image, not the page; ctrl+wheel meanwhile is ignored
- Save: a .webp is saved as a PNG copy where there is no WebP encoder (Safari)
- Text box sizing fallback where field-sizing is missing (Safari < 26.2)
- Resize dialog anchor row laid out without relying on a legend as a flex item
- apple-touch-icon for Add to Dock / Home Screen; esbuild target adds safari16.4

Co-Authored-By: Claude <noreply@anthropic.com>
…it again

The pointerdown stand-in for the blur's relatedTarget (Safari doesn't focus clicked buttons) took any
.chrome element, so such a click left the text open without focus in every browser. Now only enabled
controls count. Pinch state also resets on window blur. Smoke checks both clicks.

Co-Authored-By: Claude <noreply@anthropic.com>
…, canvas cap check

- scene.js: in WebKit the fence's 1 px texImage2D waits for the GPU (~125 ms per big repaint);
  two slow uploads in a row turn the fence off
- assets.js: without requestIdleCallback (Safari) the fallback's deadline never ran down, so a
  whole bitmap was read back in one task; it now gets 8 ms slices
- state.js: canvasFits() refuses sizes past the browser's per-canvas cap (iPadOS 8192²), which
  otherwise open blank and fail to save
- fileio.js: free the JPEG flatten canvas after encoding; keep the download URL 60 s
- docs: WebKit dropped its total canvas memory cap in 2023; open items for Safari

Co-Authored-By: Claude <noreply@anthropic.com>
- pinch: every gesture event must be cancelled, and ctrl+wheel must zoom again after gestureend
- the text box sizing fallback runs with field-sizing forced off (grows with text, fits on reopen)
- named checks for the WebKit fixes: focus leaves the committed text box; Backspace on a focused
  button keeps the page
- a downloaded .webp must carry the WEBP signature; which TIFF decoder ran is asserted per engine;
  the blocked-chunk page accepts dialogs only in WebKit

Co-Authored-By: Claude <noreply@anthropic.com>
…check script

Safari may block a download started long after the click, and the document would still look saved.
After an encode over 1 s the toast keeps a Download again button (a fresh click). Smoke checks
both the slow and the quick case. test/e2e/safari.js drives the real Safari over WebDriver; it
hasn't connected on this machine yet, so its checks are unverified.

Co-Authored-By: Claude <noreply@anthropic.com>
…by hand)

Co-Authored-By: Claude <noreply@anthropic.com>
@pathanin
pathanin merged commit 0504943 into master Oct 18, 2026
3 checks passed
@pathanin
pathanin deleted the safari-support branch October 18, 2026 12:32
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.

1 participant