Skip to content

Use OffscreenCanvas when available#27

Merged
borgar merged 1 commit intoborgar:masterfrom
flother:offscreencanvas
Sep 1, 2022
Merged

Use OffscreenCanvas when available#27
borgar merged 1 commit intoborgar:masterfrom
flother:offscreencanvas

Conversation

@flother
Copy link
Copy Markdown
Contributor

@flother flother commented Aug 29, 2022

A Google Chrome Developers session from 2019 states that OffscreenCanvas has better performance than <canvas> even when it's running on the main thread. Their benchmarks showed that:

  • OffscreenCanvas is 50% faster at creation
  • Text operations on OffscreenCanvas are 15–45% faster.

The second benchmark is of the most value to this library. It's a bit of a micro-optimisation, but it will have benefits if a lot of text measurement is going on.

OffscreenCanvas is available in Chrome and Edge (since 2018 and 2020 respectively). Other browsers will continue to use <canvas> to measure text.

A Google Chrome Developers session from 2019 states that OffscreenCanvas
has better performance than <canvas> even when it's running on the main
thread. Their benchmarks showed that:

- OffscreenCanvas is 50% faster at creation
- Text operations on OffscreenCanvas are 15--45% faster.

The second benchmark is of the most value to this library. It's a bit of
a micro-optimisation, but it will have benefits if a lot of text
measurement is going on.

<https://youtu.be/ePaUrMCL7g4?t=246>

OffscreenCanvas is available in Chrome and Edge (since 2018 and 2020
respectively). Other browsers will continue to use <canvas> to measure
text.
@borgar borgar merged commit df00f76 into borgar:master Sep 1, 2022
@flother flother deleted the offscreencanvas branch September 1, 2022 17:08
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