tldraw/packages
alex 3c1aee492a
faster image processing in default asset handler (#2441)
![Kapture 2024-01-10 at 13 42
06](https://github.com/tldraw/tldraw/assets/1489520/616bcda7-c05b-46f1-b985-3a36bb5c9476)
(gif is with 6x CPU throttling to make the effect more visible)

This is the first of a few diffs I'm working on to make dropping images
onto the canvas feel a lot faster.

There are three main changes here:
1. We operate on `Blob`s and `File`s rather than data urls. This saves a
fair bit on converting to/from base64 all the time. I've updated our
`MediaHelper` APIs to encourage the same in consumers.
2. We only check the max canvas size (slow) if images are above a
certain dimension that we consider "safe" (8k x 8k)
3. Switching from the `downscale` npm library to canvas native
downscaling. that library claims to give better results than the
browser, but hasn't been updated in ~7 years. in modern browsers, we can
opt-in to native high-quality image smoothing to achieve similar results
much faster than with an algorithm implemented in pure JS.

I want to follow this up with a system to show image placeholders whilst
we're waiting for long-running operations like resizing etc but i'm
going to split that out into its own diff as it'll involve some fairly
complex changes to the history management API.

### Change Type

- [x] `major` — Breaking change

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version

### Test Plan

1. Tested manually, unit tests & end-to-end tests pass
2024-01-10 14:41:18 +00:00
..
assets Update CHANGELOG.md [skip ci] 2024-01-10 12:03:59 +00:00
editor [improvement] account for coarse pointers / insets in edge scrolling (#2401) 2024-01-10 14:29:32 +00:00
state Update CHANGELOG.md [skip ci] 2024-01-10 12:03:59 +00:00
store Update CHANGELOG.md [skip ci] 2024-01-10 12:03:59 +00:00
tldraw faster image processing in default asset handler (#2441) 2024-01-10 14:41:18 +00:00
tlschema [improvement] account for coarse pointers / insets in edge scrolling (#2401) 2024-01-10 14:29:32 +00:00
utils faster image processing in default asset handler (#2441) 2024-01-10 14:41:18 +00:00
validate Update CHANGELOG.md [skip ci] 2024-01-10 12:03:59 +00:00