j7126 / OctoPrint-Dashboard

A dashboard for Octoprint
GNU Affero General Public License v3.0
288 stars 39 forks source link

[Bug]: Excessive network bandwidth: Webcam keeps opening new connections every time I switch to Dashboard tab #408

Open hexvolt opened 5 months ago

hexvolt commented 5 months ago

The problem

Webcam widget keeps opening new connections every time I switch to Dashboard tab, causing excessive network load.

In order to see the underlying problem, it is recommended to install Resource Monitor plugin to Octoprint or any plugin that shows network usage of the host. (It's probably irrelevant but my host is Raspberry Pi 5 running Octoprint and streaming video feed).

Steps to see the issue:

  1. Enable Webcam widget on the Dashboard plugin, and set it up pointing to the video feed.
  2. Go to the Dashboard tab, see that the video feed is properly displayed.
  3. Switch to the Resource Monitor tab in order to measure the current host network usage (e.g. upload 8Mb/s since the Dashboard has connected to the video feed and the host is streaming the video feed to the client)
  4. Go back to the Dashboard tab (apparently this is where it opens another connection to video feed, without dropping the initial one).
  5. Switch back to the Resource Monitor - you will see that network usage has doubled (e.g. upload 16Mb/s)
  6. Go back to the Dashboard tab (it will open yet another video feed connection, as if there are now 3 clients consuming the video feed)
  7. Switch to the Resource Monitor - the network usage has tripled! (e.g. 24Mb/s)
  8. ... repeat as many times as you want

In other words, if I'm just clicking the tabs in Octoprint, and it happened that I switched to the Dashboard 4 times, the network usage will quadruple!

The plugin should not open extra connections but reuse the existing one.

Version of OctoPrint

1.10.1

Platform

Raspberry Pi 5b

Operating system running OctoPrint

Rasspberry OS 64 bit Bookworm

Dashboard version

1.19.11

Python version

3.11

Printer model & used firmware incl. version

Prusa i3 MK3S+

Browser and version of browser, operating system running browser

Safari and Chrome on MacOS, iPad OS

Logs and other files needed for analysis

File uploads & additional information

https://github.com/j7126/OctoPrint-Dashboard/assets/3257103/eda84ff8-03f4-4a34-ac99-2f66c48130e0

octoprint-systeminfo-20240604135838.zip