binarymax / floodfill.js

HTML5 Canvas Floodfill via JavaScript
MIT License
57 stars 14 forks source link

Perfomance Improvements // Profiling #11

Closed Miserlou closed 7 years ago

Miserlou commented 7 years ago

Is there anything we can do to improve the performance of this library, perhaps by parallelizing it?

I really like it, but unfortunately it causes an unresponsive script error in Firefox (seems okay in Chrome) - any advice?

Miserlou commented 7 years ago

Okay, after a little poking around, it looks like the performance issue is probably in my code, not yours. :)

binarymax commented 7 years ago

Hi @Miserlou, would you mind sharing what you did on your end that caused perf issues? It might help others in the future. Thanks.

Miserlou commented 7 years ago

Turns out that Firefox's (<52) calls to getImageData() are very slow, my application was calling this method a lot when deciding when to floodfill. My (as yet unimplemented) strategy to mitigate this was the call getImageData for a larger area and check the stored bytes instead of calling it for every look up. This seems particularly bad for large, high-dip screens.

Related ticket in Firefox Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1001069

binarymax commented 7 years ago

Thanks @Miserlou. As this is not a floodfill bug, closing this issue.