0

The title says it all. I was having a hang in our kiosk app after hours or days of our app working. I distilled it to CDhtmlDialog's Navigate(), or whatever it does.

Windows 10, Visual Studio 2013 Community Edition, MFC in shared DLL

Reproduced the issue in a bare-bones, freshly generated MFC dialog-based app that has a CDHtmlDialog-based modal dialog.

In that Dialog, all I do is set up a timer that calls every second or so to reload a page. Here is the timer routine.

void CDHtmlStressDlg::OnTimer(UINT nIDEvent)
{
  Navigate(L"C:\\temp\\html\\test.html");
}

After a few hundred to a few thousand loads (not deterministic) - the entire UI freezes. If I try posting amessage to the window (which is what I tried in my old app) - I get error 1816 - (not enough quota). Dont know if its relevant, just one thing I observed.

Here is the thread dump after a hang (note, I do not create any threads of my own, this is all MFC stuff):

Not Flagged     764 0   Worker Thread   msvcrt.dll!_threadstartex   jscript9.dll!Event::Wait    Normal
Not Flagged     6368    0   Main Thread Main Thread mfc120ud.dll!51fbbc54   Normal
Not Flagged     7228    0   Worker Thread   ntdll.dll!TppWorkerThread   ntdll.dll!_NtWaitForWorkViaWorkerFactory@20 Normal
Not Flagged     7936    0   Worker Thread   ntdll.dll!TppWorkerThread   ntdll.dll!_NtWaitForWorkViaWorkerFactory@20 Normal
Not Flagged     4284    0   Worker Thread   ntdll.dll!TppWorkerThread   ntdll.dll!_NtWaitForWorkViaWorkerFactory@20 Normal
Not Flagged     7844    0   Worker Thread   msvcrt.dll!_threadstartex   mshtml.dll!Memory::Recycler::ThreadProc Below Normal
Not Flagged     7252    0   Worker Thread   mshtml.dll!CExecFT::StaticThreadProc()  mshtml.dll!Memory::HeapBucketT<Memory::SmallNormalHeapBlockT<SmallAllocationBlockAttributes> >::SweepBucket Normal
Not Flagged     7172    0   Worker Thread   ntdll.dll!TppWorkerThread   ntdll.dll!_NtWaitForWorkViaWorkerFactory@20 Normal
Not Flagged     7176    0   Worker Thread   mshtml.dll!CExecFT::StaticThreadProc()  mshtml.dll!CTimerMan::ThreadExec    Normal
Not Flagged     6252    0   Worker Thread   ntdll.dll!TppWorkerThread   ntdll.dll!_NtWaitForWorkViaWorkerFactory@20 Normal
Not Flagged     7812    0   Worker Thread   winmm.dll!mciwindow win32u.dll!_NtUserGetMessage@16 Highest
Not Flagged >   5836    0   Worker Thread   mshtml.dll!CExecFT::StaticThreadProc()  combase.dll!CCliModalLoop::BlockFn  Normal
Not Flagged     404 0   Worker Thread   mshtml.dll!CExecFT::StaticThreadProc()  combase.dll!CCliModalLoop::BlockFn  Normal
Not Flagged     6920    0   Worker Thread   msvcrt.dll!_threadstartex   jscript9.dll!Recycler::ThreadProc   Below Normal

And here is the html I'm loading

<!DOCTYPE html>
<html>
<head>
    <style>
        body {
            overflow: hidden; /*suppress scroll bars*/
        }

        .box {
            display: inline-block;
            border-spacing: 0;
            border-collapse: collapse;
            font-family: Arial;
            transform: rotate(90deg);
            display: inline-block;
        }

        .line1 {
            font-size: 210%; 
            color: Coral;
            width: 1100px;
            transform: translate(45%, 1120%); 
            text-align: center;
        }

        .pic1 {            
            width: 230px;
            transform: translate(0%, -30px);
        }
    </style>
</head>

<body id=CHtmlMirror bgcolor=black>

    <div class="box">
        <div class="line1">Test Line to load</div>
    </div>

    <table border=0 class="pictureTable">
        <tr><td><p><img class="pic1" src=file://c:/temp/icons/pic1.jpg></p></td></tr>
    </table>

</body>
</html>
user2349195
  • 62
  • 1
  • 8
  • 1
    Is your UI spread across more than one thread? – IInspectable Apr 11 '17 at 23:58
  • I do not do any additional threading on top of what MFC generates. Literally, just adding a few lines of code to add the timer and load a page. – user2349195 Apr 12 '17 at 00:11
  • So, to clarify, yes, everything "I do" is happening on the main UI thread – user2349195 Apr 12 '17 at 02:12
  • Could you try Navigate2 method instead of Navigate ... just a thought ... – Flaviu_ Apr 12 '17 at 06:40
  • look at gdi & user object. maybe you can create a dog watch program and restart the kiosk when it happens – alangab Apr 12 '17 at 09:25
  • 1
    Could this be of any help: http://stackoverflow.com/questions/38147194/iwebbrowsernavigate-deadlock-after-a-ole32-dll-exception – VuVirt Apr 12 '17 at 10:10
  • Thanks for suggestions. Navigate2 is a CHtmlView member, my code is using CDHtmlDialog (I'll see how much effort there is in switching to CHtmlView to give this a try). – user2349195 Apr 12 '17 at 15:20
  • Re: Watchdog - yeah, that's always a possibility, unfortunately this hang can happen in the middle of a paid session - and restoring the state after termination is a big pain. – user2349195 Apr 12 '17 at 15:21
  • Confirmed the same issue with CHtmlView. Hngs just like CDHtmlDlialog ... BTW - observed one more thing - the more img tags there there are - the faster it hangs. With 6 images - it often does not even reach a 1000 before hanging for good. – user2349195 Apr 12 '17 at 16:58
  • Add a callstack of the main thread at least. – KonstantinL Apr 14 '17 at 07:34
  • VS says stack not available. – user2349195 Apr 14 '17 at 23:49
  • [Debugging with Symbols](https://msdn.microsoft.com/en-us/library/windows/desktop/ee416588.aspx). – IInspectable Apr 15 '17 at 11:25

1 Answers1

0

This problem is only reproducible when the HTML page being loaded is also being modified from an external app (or thread, does not matter). There are no loading errors in that case - just a "terminal case" UI freeze.

To work around this, we ensured that no one could touch the file while it was begin loaded. Once this was guaranteed, the hang could not be reproduced.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
user2349195
  • 62
  • 1
  • 8