Skip to content

Performance and support ​

Phone photos have 12 megapixels or more, and editing them takes real work. This page explains where that work runs, what your build and your server need, and which browsers PaperPic supports.

A Web Worker does the work ​

Black and white and Straighten take about a second and a half on a 12-megapixel photo on a recent phone, as the measured times show. On the main thread, the page would freeze for that long. PaperPic runs them in a Web Worker instead, so the page keeps responding while Apply runs. Straighten also looks for the document there.

The worker ships inside the package and starts with the standard new Worker(new URL(…, import.meta.url)), which bundlers such as Vite and webpack 5 pick up on their own, with no configuration. If the worker cannot start, the editing runs on the main thread: it still works, but the page can freeze for a moment with large images.

Content Security Policy ​

With a Content Security Policy, allow:

  • worker-src 'self', for the worker.
  • img-src blob:, because the viewer shows attached files and the results of Apply through blob: URLs.
  • paperpic in trusted-types, if your policy restricts Trusted Types policies, because the icons of the buttons go through that policy.
  • A default Trusted Types policy whose createScriptURL accepts the URL of the worker, if your policy requires Trusted Types. Bundlers only pick up a worker created from a plain URL, which Trusted Types block, so without that policy the editing runs on the main thread.

Large photos ​

  • While editing, the preview works on a copy of about 2 megapixels, so rulers and tools stay fluid with any photo.
  • On Apply, every edit runs at full resolution. Large photos take a few seconds, so the viewer shows a message and blocks the controls meanwhile.
  • To save time and memory, set maxOutputSize. A limit such as 2000 or 3000 pixels keeps documents readable, and makes Apply faster and the files smaller.

Measured times ​

Each step of Apply, in the worker, on a Pixel 10 Pro with Chrome 156:

Step2 MP12 MP37.5 MP
Black and white256 ms1.5 s4.8 s
Straighten251 ms1.6 s5.0 s
Export to PNG92 ms378 ms979 ms
Export to JPEG, quality 0.933 ms142 ms525 ms
  • A move of the ruler of Clean up takes about 40 ms on the same phone, because it works on the preview of about 2 MP.
  • A desktop computer with 8 cores does each step about six times faster.
  • At 37.5 MP, black and white needs about 340 MB of memory at its peak.
  • Mid-range Android phones and iPhones are not measured yet.

Server-side rendering ​

PaperPic needs a browser. The Vue and React components render an empty element on the server, such as in Nuxt or Next.js, and create the viewer in the browser. With the core, create the viewer in the browser yourself, such as when your component mounts.

Browser support ​

PaperPic supports the browsers of Baseline Widely Available: the features that have worked in all the major browsers for at least 30 months. The packages are built for that target, which means Chrome and Edge 124, Firefox 125 and Safari 17.5 or newer, so you do not need to transpile them.

Released under the MIT License.