WebBrowser control not processing Javascript timers after sleep on Windows 8.0

312 Views Asked by At

I have a WPF C# app with a WebBrowser control. The app gets run on three different tablet configurations: Windows 7 with IE9, Windows 8.0 with IE10 (supports connected standby), and Windows 8.1 with IE11 (also supports connected standby).

If we let the tablets go to sleep with our app running for an hour or more and then wake them up, on the Windows 8.0 tablet, Javascript timer callbacks no longer get called. Neither already running timers nor new ones work. (I added some logging and Javascript itself still runs - click handlers and the like). The Windows 8.1 tablet and the Windows 7 tablet are both fine in this scenario.

I set up a simple test page with just a 1 hour timer and a button to set a short timeout. (This is similar to the app's timeouts). I see the same behaviour on the test page: on the Win8.1 and Win7 tablets, when you wake them up after sleeping for an hour or more, the 1 hour timer callback is called soon after, and the callback from the button's timeout also works. But on the Windows 8.0 tablet, neither of the timer callbacks run.

Test page code:

Automatic Hour Counter: <label id="autoCounter">0</label><br>
Manual Counter: <label id="manualCounter">0</label><br>
<button id="manualCount">Set timer for manual counter</button>

<script>
var autoCounter = 0;
var manualCounter = 0;

setInterval(function() {
    autoCounter++;
    $("#autoCounter").text(autoCounter);
}, 3600000);

$("#manualCount").click(function() {
    setTimeout(function() {
        manualCounter++;
        $("#manualCounter").text(manualCounter);
    }, 100);
});
</script>

If absolutely necessary we may be able to upgrade the Win8.0 devices, but we're hoping to avoid that for a few reasons.

Has anyone seen this? Any ideas?

Edit: I tried the test page in IE10 on the Win8 tablet. It works fine, so the issue's only occurring with the WebBrowser control.

Edit 2: I found a workaround.

If I add a setInterval() call with a short timeout, then after the device wakes up the other timer callbacks all work. 15 seconds works, 30 seconds doesn't, and I'm not going to bother to narrow it down further.

I'm going to leave the question open instead of posting this as the answer because I still hope someone has a proper solution. :)

0

There are 0 best solutions below