Page 1 of 1

Fix for montage view camera freezes

Posted: Wed Sep 09, 2009 11:39 am
by yanychar
When a stream socket is closed on the server, the picture freezes. The patch installs an onLoad listener for each camera in montage view and launches a checker. The latter examines the latest load time for each picture and re-queries the stream, if necessary.

Code: Select all

diff --git a/web/skins/classic/views/js/montage.js b/web/skins/classic/views/js/montage.js
index 9852f6d..4c5fae8 100644
--- a/web/skins/classic/views/js/montage.js
+++ b/web/skins/classic/views/js/montage.js
@@ -114,14 +114,54 @@ function changeScale()
     }
 }

+function reloadFrame(index)
+{
+    var streamImg = document.getElementById( 'liveStream'+monitors[index].id );
+    var imgSrc = streamImg.getAttribute("src");
+    var newImgSrc = imgSrc.substring(0, imgSrc.length - 1);
+    newImgSrc = newImgSrc + Math.floor(10*Math.random());
+    streamImg.setAttribute("src", newImgSrc);
+}
+
+var checkRun = 0;
+
+function checkFrame()
+{
+    var d = new Date();
+    var t = d.getTime();
+    for ( var i = 0; i <monitorData> 2500) {
+                reloadFrame(i);
+            }
+        }
+        catch (e) {
+            if (++checkRun < 3)
+                alert(e);
+        }
+    }
+}
+
+function onFrameLoad(index)
+{
+    var d = new Date();
+    monitors[index].loadStamp = d.getTime();
+    $('loadStamp' + index).set( 'text', d.toLocaleTimeString());
+}
+
 var monitors = new Array();
 function initPage()
 {
+    setInterval("checkFrame()", 1000);
+    var f;
     for ( var i = 0; i <monitorData>
-            <div><SLANG>:&nbsp;<span></span>&nbsp;-&nbsp;<span></span>&nbsp;fps</div>
+            <div><SLANG>:&nbsp;<span></span>&nbsp;-&nbsp;<span></span>&nbsp;fps&nbsp;-&nbsp;<span></span></div>
 <php>

Posted: Thu Sep 10, 2009 5:04 am
by sef1976
thanks
but you list not full source

Posted: Fri Sep 11, 2009 10:08 am
by yanychar
What are you trying to say?
sef1976 wrote:but you list not full source
I filed a patch, not full source.

Posted: Sat Sep 12, 2009 5:19 am
by sef1976
i know
but his not installed
tried it

Posted: Wed Dec 09, 2009 4:49 pm
by yanychar
I did get it fast enough. The patch was not complete. Corrected version follows.

Code: Select all

diff --git a/web/skins/classic/views/js/montage.js b/web/skins/classic/views/js/montage.js
index 9852f6d..fd7b522 100644
--- a/web/skins/classic/views/js/montage.js
+++ b/web/skins/classic/views/js/montage.js
@@ -114,14 +114,55 @@ function changeScale()
     }
 }
 
+function reloadFrame(index)
+{
+    var streamImg = document.getElementById( 'liveStream'+monitors[index].id );
+    var imgSrc = streamImg.getAttribute("src");
+    var newImgSrc = imgSrc.substring(0, imgSrc.length - 1);
+    newImgSrc = newImgSrc + Math.floor(10*Math.random());
+    streamImg.setAttribute("src", newImgSrc);
+}
+
+var checkRun = 0;
+
+function checkFrame()
+{
+    var d = new Date();
+    var t = d.getTime();
+    for ( var i = 0; i <monitorData> 2500) {
+                reloadFrame(i);
+            }
+        }
+        catch (e) {
+            if (++checkRun < 3)
+                alert(e);
+        }
+    }
+}
+
+function onFrameLoad(index)
+{
+    var d = new Date();
+    monitors[index].loadStamp = d.getTime();
+    $('loadStamp' + index).set( 'text', d.toLocaleTimeString());
+}
+
 var monitors = new Array();
 function initPage()
 {
+    setInterval("checkFrame()", 1000);
+    var f;
     for ( var i = 0; i < monitorData.length; i++ )
     {
         monitors[i] = new Monitor( i, monitorData[i].id, monitorData[i].connKey );
         var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout );
         monitors[i].start( delay );
+        var streamImg = document.getElementById( 'liveStream'+monitors[i].id );
+        eval('f = function() { onFrameLoad(' + i + ');}');
+        streamImg.addEventListener("load", f, false);
     }
     selectLayout( $('layout') );
 }

Help for a new user

Posted: Sat Dec 19, 2009 6:55 am
by L0key
hey yanychar,

I know this is a path for zoneminder in the montage view. And I think its php.

so my question is ... how do I apply it :cry:

Posted: Sat Dec 19, 2009 4:40 pm
by whatboy
I think... you need to save the code to "patch-file-name" in ZoneMinder-1.24.2/web/skins/classic/views/js folder then run this command

patch -p0 < patch-file-name

or maybe just save the file in ZoneMinder-1.24.2 source and apply it... and recompile and reinstall, if you didn't compile the source yourself it is useless...

Posted: Wed Dec 01, 2010 3:50 pm
by grndamgt4
whatboy wrote:I think... you need to save the code to "patch-file-name" in ZoneMinder-1.24.2/web/skins/classic/views/js folder then run this command

patch -p0 < patch-file-name

or maybe just save the file in ZoneMinder-1.24.2 source and apply it... and recompile and reinstall, if you didn't compile the source yourself it is useless...
I modified the path in the patch to be correct on my install but I get

root@zoneminder1:/usr/share/zoneminder/skins/inferno/views/js# patch -p0 < patch.txt
patching file b/montage.js
patch: **** malformed patch at line 58:

root@zoneminder1:/usr/share/zoneminder/skins/inferno/views/js#