4

The page connects via WebSocket to the server and requests a constantly changing frame of the broadcasting web camera:

<script>
    function Initialize(){
        var Screen = document.createElement('img');
        Screen.onload = function(){URL.revokeObjectURL(Screen.src);};
        document.body.appendChild(Screen);
        var Rate = 50;
        var Preload = new Image();
        var Request = 'GetFrame';
        var Socket = new WebSocket(<?php echo $host;?>);
        Socket.onopen = function(){Socket.send(Request);};
        Socket.onmessage = function(event){
            if (Preload.src.length > 0){Screen.src = Preload.src;}
            Preload.src = URL.createObjectURL(event.data);
            setTimeout(function(){Socket.send(Request);},Rate);
        };
    }
</script>
...
<body onload="Initialize();"></body>

In regular Chrome, in Firefox and IE images change smoothly like video, even without Preload - just Screen.src = URL.createObjectURL(event.data). And in Chromium version 61, which customers insist on, the frames blink on loading!

Is it possible to fix this blinking in Chromium 61?

Iceman
  • 365
  • 1
  • 3
  • 17
  • Not going to suggest it as a duplicate, because your bug may be elsewhere, but see: https://stackoverflow.com/q/3511200/1180785 – Dave Jul 14 '17 at 07:43
  • @Dave, I tried to add onload event to my Preload variable src, where I set the Screen.src = Preload.src, but no result - still blinking. I also tried to create an array of images and set Screen.src = Preload[0].src and than perform Preload.shift() - but no... it's blinking – Iceman Jul 14 '17 at 07:50
  • 1
    Since 61 is still in early development, it's possible you're hitting a bug in the engine which will be fixed before release. If I were you I'd make a reduced example of the bug (e.g. no streams, just hard-code 2 object URLs and switch between them), and if the flicker is still happening, report a bug. This will also help you narrow down the issue if it does turn out to be your code doing something dodgy. Note that your users insisting on Chrome 61 means they should **expect** bugs like this, since that's the point of pre-release (I'm guessing they're testing their own app for compatibility?) – Dave Jul 14 '17 at 11:48
  • 1
    If it does turn out to be a bug in Chrome and you really need a workaround, I'd suggest keeping 2 img tags on the page and toggling their `display:hidden`. Then you can set one image, wait for it to load, switch the display, set the other image, etc. It's the same principle you have now, but less elegant and perhaps not as likely to hit the issue. If even that doesn't work, you could `position:absolute` the loading image somewhere off-screen while it loads. Obviously these are just workarounds; you'd be better waiting for a fix in this situation. – Dave Jul 14 '17 at 11:51

0 Answers0