fluidd-core / fluidd

Fluidd, the klipper UI.
https://docs.fluidd.xyz
GNU General Public License v3.0
1.34k stars 401 forks source link

refactor(cameras): use cached url object for adaptive MJPEG sources #1327

Closed matmen closed 5 months ago

matmen commented 5 months ago

Resolves an error when destroying an adaptive MJPEG camera feed: image

Profiling showed this also improves handleRefresh performance by ~15% (1.97ms vs 1.67ms).

matmen commented 5 months ago

@pedrolamas Moving the URL instantiation outside of the handleRefresh method was intentional, no point in creating a new object 30 times a second 😉 Maybe removing the cameraImageSource altogether and replacing it with a url object is the way to go here?

pedrolamas commented 5 months ago

Moving the URL instantiation outside of the handleRefresh method was intentional, no point in creating a new object 30 times a second 😉

Ah, fair point on that! This type of code has been in for ages, but indeed I see no reason why we shouldn't change it to a more "optimized" approach.

Maybe removing the cameraImageSource altogether and replacing it with a url object is the way to go here?

I tried it and doesn't work without other changes because the URL instance is always the same so Vue doesn't raise a change notification.

I'll refactor back to 2 properties!