From 504dd266d4db487c406becd8a89dd000491f3194 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sun, 1 Dec 2013 15:13:27 +0200 Subject: [PATCH] added a checker for camera errors that get stuck on loading --- src/handlers.py | 3 +++ static/js/main.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/handlers.py b/src/handlers.py index b285aa2..ef4daed 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -629,6 +629,9 @@ class PictureHandler(BaseHandler): if camera_id not in config.get_camera_ids(): raise HTTPError(404, 'no such camera') + import time + time.sleep(100) + camera_config = config.get_camera(camera_id) if camera_config['@proto'] != 'v4l2': def on_response(response): diff --git a/static/js/main.js b/static/js/main.js index df7be01..c48a7ae 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1904,6 +1904,20 @@ function refreshCameraFrames() { setTimeout(refreshCameraFrames, 100); } +function checkCameraErrors() { + /* properly triggers the onerror event on the cameras whose imgs were not successfully loaded, + * but the onerror event hasn't been triggered, for some reason (seems to happen in Chrome) */ + var cameraFrames = $('div.page-container').find('img.camera'); + + cameraFrames.each(function () { + if (this.complete === true && this.naturalWidth === 0 && !this.error) { + $(this).error(); + } + }); + + setTimeout(checkCameraErrors, 500); +} + /* startup function */ @@ -1935,5 +1949,6 @@ $(document).ready(function () { initUI(); fetchCurrentConfig(); refreshCameraFrames(); + checkCameraErrors(); }); -- 2.39.5