Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE10 JavaScript cannot repaint window while computer is locked?

The Problem

Occurs on IE10. (IE8 works fine.)

I've written some JavaScript code that, after 20 minutes of inactivity, redirects the browser to another URL to indicate the user was logged out. Normally this works fine. However I've noticed a strange scenario.... if the user's Windows computer was locked during this timeout then it appears as though nothing has happened.

However, when I look at the browser's URL bar, I can clearly see that the URL has already been updated to the auto-logout page. But the entire content of the browser window is still displaying the old page!!!! For some reason, the browser window has not repainted / refreshed. It looked like it had frozen.

At this point... if I rapidly mouse click around on the page then the browser "wakes up" and shows the new content. (It seems that just one mouse click is not enough. The more rapidly you click around, the faster it "wakes up".)

Theory

My best guess is the IE10 browser stops repainting the window while the computer is locked. However, I do believe the JavaScript engine is still running though, because I tested another scenario with multiple JS new Date() time stamps at various intervals and when the screen finally repainted, each date time was unique, showing the time it actually occurred.

Recreating the Issue - version 1

  1. Launch the JavaScript code below in IE10
  2. Lock my Windows computer before 10 seconds has elapsed.
  3. Wait 10 seconds, and then unlock my computer.
  4. See the IE10 window has failed to repaint.

I did notice this only occurs when redirecting to a URL on our company's local intranet. I have no idea why this is the case.... but if I have the URL as Google or Yahoo's home page.... then I cannot recreate the issue. It just works correctly. Made me wonder if it could be a Group Policy / Trusted Zones / Intranet vs Internet issue of some sort...

<!DOCTYPE HTML>
<html>
<head></head>
<body>    
<script>
    var url = 'http://IntranetWebApps.OurCompany.com/MyWebApp/Home';  // fails
    //url = 'http://www.yahoo.com';  // this 'Internet' site works
    //url = 'http://www.google.com';  // this 'Internet' site works 

    setTimeout(function () { 
            window.location.href = url;
        }, 10000  // wait 10 seconds, then execute redirect
    );
</script>
</body>
</html>

Question

Does anyone have any ideas how to solve this issue, so that the IE10 window will always repaint instantly instead of displaying stale content?

like image 395
ClearCloud8 Avatar asked Mar 04 '14 23:03

ClearCloud8


2 Answers

Finally found a way to overcome this ridiculous annoyance. I added some JavaScript to my auto-logout landing page (where I was redirecting the users). This JavaScript updates the page content every one second.

Voila!

The real issue here is that even if the IE10 window content was legitimately updated and ought to repaint (such as when a redirect occurs) while the computer was locked..... it will not repaint.

IE10 only repaints if the page content update action occurs WHILE the computer is unlocked.

The JavaScript below updates the page content every one second, by setting the DIV's content to the current time, including seconds. This means if the user locks their computer and goes to lunch for an hour, their browser page will be timed out and redirected to the logout page while they are gone. When the user comes back and unlocks their computer... they will see the old stale content for 1 second.... and then the running JavaScript forces a repaint, and they will quickly see the logout screen's content.

<h1>Due to inactivity, you were automatically logged out.  (Deal with it.)</h1>
<div id="div1" style="background-color: white; color: white;">
</div>
<script>
    (function ()
    {
        var forceRepaint = function ()
        {
            var myDiv = document.getElementById("div1");
            myDiv.innerHTML = new Date().toLocaleTimeString();
        };
        setInterval(forceRepaint, 1000);
    })();
</script>

I did try things like just setting the visibility on the DIV to make it hidden (instead of setting white background and white text color), but the browser will not repaint. It's very intelligent about detecting if a visible change has really occurred.

BONUS -- Yahoo/Google versus my Logout page

The reason I could not create the issue when redirecting to external sites like Yahoo or Google was that they probably had some JavaScript code running that would indeed update their page's content after it had loaded. They essentially had more 'stuff' going on. Whereas my original logout page was very plain and did not have any JavaScript code executing on page load.

like image 102
ClearCloud8 Avatar answered Nov 20 '22 17:11

ClearCloud8


I suspect this might be specific to particular set of graphics cards or drivers. From the IE menu bar, select Internet Options. On the advanced tab, select the "Use software rendering" option. Then reboot.

like image 2
selbie Avatar answered Nov 20 '22 18:11

selbie