FireFox freezing Repetier Server sometimes - webcam issue?
Hi, it seems that since Firefox 74.0 Repetier Server freezes sometimes
when accessing some page where webcam is embedded. The page does not
freeze if the webcam is unavailable. It also does not freeze if i use
that MS Edge instead.
Did anyone get the same experience?
At the moment i have no idea how to fix that.
The inspector console says nothing and firefox won't show a freeze
popup (the yellow var that some script slows down).
But instead the page crashes with the result of an endless round
spinner or the controls are just not able to use but page is visible as
usual/mouse can move but nothing clickable.
Comments
would it be a fix to have some control service on raspberry pi which looks for dangling port connections? with lsof there are sometimes some port states "CLOSE_WAIT" from mjpg_streamer
What do you do to produce the firefox hang? Does it stop working without switching a page or when you switch from page xy to anything else?
If you can, please use it with open network in debug and when it freezes again have a look on the open connections without a status (sort status ascending and they are at top). If you have around 6 which is the limit I think nowadays check the urls - if they all belong to cammjpg it is not closing them when you switch pages. Do you use home page with webcams and how much do you have there? Maybe it gets a problem if we have to many cams on one page and then it doe snot manage to close them correctly.
I see you hat 3 websocket connections, so you lost 2 times connection, but you said internet was not that stable so no problem. I get it quite often when I recompile server and no problems with that.
So now that we know it is not the webcam that blocks firefox there must be something else being wrong. If you still have it open can you open the latest connection to /socket and check messages. The last 20 or so are of interest. Something must block the browser - also I would expect the not responding message then. Anyhow it might be a unusual message also since it does not happen on chrome/edge it must be something that is handled differently in firefox and not directly wrong. And the fact that it depends on a webcam is strange - webcam does not require different messages. They are opened outside the websocket. And no error in console is also not indicating anything. Pausing javascript might be an idea, but it is compressed so it is hard to read what it does.
#
I also see the long time load is low compared to short time load so something has happened increasing the load. So much is sure.
When you hit F2->Display options->Show custom thread names you will see wat type of thread in server is taking the high load. Activate also "update thread name on every refresh " if you do not see the name. cammjpg is the name for active webcam stream. Each open webcam stream creates one such thread. My cause 4% load but I have low resolution 640x480 so might differ. Assuming these are your webcam streams - how high is the load there normally and what resolution/framerate do you use? Question is mainly is 35-50% normal load or particular high if it is webcam stream.
Does reloading firefox reduce load significantly?
I see server has 8.5% load with mjpg forwarding. Not much compared with apache having 35% at the same moment. One problem with proxy is when they start buffering data. I had big delays in webcam streams in the past when bandwidth was too low. So now we dynamically drop images from the stream when that happens. Works great unless a part in between like apache would start buffering the data. From memory usage it seems not to do that - at least not in ram.
But you think it only happens without proxy. That would be just one stage less. Apache queries on port 3344 just as you do when you use it directly. That would mean if the http client is apache there is no problem and if the client is firefox a problem can happen.
Why is the apache load so high when you have the error accessing server locally? Is it normally also that high? On my pi 4 nginx has 6-7% cpu load when viewing a stream 640x480.
I also still do not make the connection to the website freezing - website freezes if the websocket does not send data and that is unrelated to webcam. Only if this causes a deadlock but then reloading webpage would not work.
Really hard to find a cause if it happens only to others so you can not debug it on your own. And the fact that it only happens in new firefox versions make me believe that they handle something different causing the problem. So you would need to debug the firefox side why it gets unresponsive. open networks, javascript and what it tries to do... not easy with production code that is optimized and minimized.
refactoring this issue after a series of new tests to the following short facts
- using: Repetier Server 0.92.1, mjpg_streamer, Raspbian Buster, latest apache2
- Google Chrome Repetier Server is running fine - no freeze (tested with localhost on 3344 and also remote forwarding with apache proxy)
- Repetier Server Monitor is running fine - no freeze (tested with localhost on 3344 and also remote forwarding with apache proxy)
- Firefox is running fine remotely (always), but freezes on localhost port 3344 (always)
- turning off apache does not change anything
Maybe somebody has some more ideas now. Maybe there's some setting in Firefox about threading or decoding.
Anyhow knowing resolution/fps is an issue I tested again. Now I get my firefox to freeze on first view if a webstream is contained that is so big. Nginx proxy did also not work. Using mjpg_streamer web surface directly also did not work. So in my case it does not work in any case. All I see is a FirefoxCP Web Content process taking around 100% CPU and nothing works. So looks like firefox is too slow to compress the stream and gets stuck somehow. Will test a bit further to see what happens if load is < 100%. My guess is that this is the requirement to not freeze.
Since you mentioned timelapse - the FPS has no influence on it at all. For timelapse we fetch the image independently from any mjpg streams.
- 10 FPS: Works good on firefox, cpu load 75-90%
- 15 FPS: Lagging stream, not usable cpu load 125%
- 30 FPS: Total freeze, cpu > 100%
So the truth is that high res mjpg is just causing too much cpu load on firefox breaking user experience. Chrome has 70% load for the 15FPS stream. And I guess they just skip frames if they can not decompress fast enough and make it healthy that way.
So I see only 2 solution:
1. Use chrome
2. Reduce FPS or resolution