Jacob-Griffin / TelephonePictionary2.0

New version of blowyourfaceoff.com using more modern web technology than php and raw javascript
https://byfo.net
0 stars 0 forks source link

Double check canvas performance #31

Closed Jacob-Griffin closed 2 months ago

Jacob-Griffin commented 8 months ago

I forget who commented on this, but I'm starting to see it myself: the canvas events feel a bit choppy. It doesn't take too much speed to get a somewhat jagged line. It's possible there's an issue with event frequency or how much lifting I'm putting on a mouse event, but I think there's something to be done.

Jacob-Griffin commented 8 months ago

I made a few changes to the canvas component, cutting out a bit of unnecessary work. The jaggedness on fast motions does still exist, but how fast you need to squiggle to encounter it is much higher. This might come up again with any enhancements to canvas, but at the moment, performance is pretty good again

Jacob-Griffin commented 3 months ago

Seems that particularly slow systems can still run into issues here, worth another look

Jacob-Griffin commented 3 months ago

There was definitely some bloat in here:

I was fetching the canvas bounding box every frame of drawing, but it's kind of an expensive operation for such a frequent event. By making that compute once on start draw, I made it like twice or three times as fast.

I also opted to not make a big string with the current path, but just work with an array and convert to string on demand (it was once per redo)

Performance issues should be pretty far mitigated but I'll leave it open for testing

Jacob-Griffin commented 3 months ago

Another note: While testing this, I found out that there's an issue that exclusively affects firefox and firefox-based browsers, on their first line I'll open a new issue and link here

Jacob-Griffin commented 2 months ago

The canvas performance seems reasonable for most systems/browsers. The problem case does not seem reasonable to try and maintain, and is likely something we can solve on the players end. There's not much else to be done performance wise.