vincentriemer / react-native-dom

An experimental, comprehensive port of React Native to the web.
https://rntester.now.sh
MIT License
3.25k stars 73 forks source link

Text measurement #23

Open NekR opened 6 years ago

NekR commented 6 years ago

I know it's too early for speed optimizations, just wanted to point out some way of doing so for text measurement, because it's what runs frame rate in the app right now (it forces browser layout).

So the more optimized way for main thread might measuring with <canvas>'s 2d context's measureText() API. Which measure itself most likely won't be any faster, it won't be causing any forced layout issues in the DOM.

For the off-thread measurement, OffscreenCanvas probably can be used, once it's implemented and supports 2d context rendering.

Just wanted to file this issue so it could be tracked by others or additional thoughts added.

Great work! 🎉

kripken commented 6 years ago

Another option while waiting for OffscreenCanvas is to use FreeType compiled to wasm like some other web apps do.