Fix for montage view camera freezes

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
yanychar
Posts: 4
Joined: Sun Jul 05, 2009 8:29 pm

Fix for montage view camera freezes

Post 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>
sef1976
Posts: 46
Joined: Sun Aug 16, 2009 5:24 am

Post by sef1976 »

thanks
but you list not full source
yanychar
Posts: 4
Joined: Sun Jul 05, 2009 8:29 pm

Post by yanychar »

What are you trying to say?
sef1976 wrote:but you list not full source
I filed a patch, not full source.
sef1976
Posts: 46
Joined: Sun Aug 16, 2009 5:24 am

Post by sef1976 »

i know
but his not installed
tried it
yanychar
Posts: 4
Joined: Sun Jul 05, 2009 8:29 pm

Post 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') );
 }
L0key
Posts: 4
Joined: Sun Nov 29, 2009 3:03 am
Location: The Gathering Place

Help for a new user

Post 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:
"Knowledge, without action, is useless. It's not what you learn, it's what you live."

Dr Kyla Dillard
whatboy
Posts: 304
Joined: Mon Aug 31, 2009 10:31 pm

Post 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...
grndamgt4
Posts: 24
Joined: Tue Oct 13, 2009 5:05 pm

Post 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#
Post Reply