Stack overflow, when using touch input.

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Stack overflow, when using touch input.

Postby FinitelyFailed » Wed Oct 07, 2015 8:23 am

Hi

I'm running CEF3 2171, on Windows 8.1 x64. I do the following:
  • Load a URL, which shows a webpage with a lot of (text input) forms, lik a form where one enters shipping information.
  • Write a lot of stuff into the form, using the windows touch keyboard (tabtip).
  • Tap on the first field that I entered a lot of text into.
  • Tap on backspace, one or several times.
  • In release mode the app just crash and in debug I get a stack overflow (see below).

It was first discovered in the app I am writing but the same thing happens in the CEF example app (cefsimple).

Note that it only seem to happen when using touch input, when using a mouse and keyboard it doesn't happen.

Code: Select all
Unhandled exception at 0x000000018061794F (libcef.dll) in player.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x000000F6ECBD3FD8).


Stacktrace:
Code: Select all
   ntdll.dll!RtlpAllocateHeap()   Unknown
    ntdll.dll!RtlAllocateHeap()   Unknown
    ntdll.dll!RtlDebugAllocateHeap()   Unknown
    ntdll.dll!RtlpAllocateHeap()   Unknown
    ntdll.dll!RtlAllocateHeap()   Unknown
    user32.dll!EnumDisplaySettingsExW()   Unknown
    libcef.dll!`anonymous namespace'::GetDisplay(tagMONITORINFOEXW & monitor_info) Line 40   C++
    libcef.dll!gfx::ScreenWin::GetDisplayNearestWindow(aura::Window * window) Line 139   C++
    libcef.dll!views::`anonymous namespace'::GetOrigin(const aura::Window * root_window) Line 21   C++
    libcef.dll!views::DesktopScreenPositionClient::ConvertPointToScreen(const aura::Window * window, gfx::Point * point) Line 53   C++
    libcef.dll!aura::`anonymous namespace'::SetLastMouseLocation(const aura::Window * root_window, const gfx::Point & location_in_root) Line 54   C++
    libcef.dll!aura::WindowEventDispatcher::DispatchMouseEnterOrExit(const ui::MouseEvent & event, ui::EventType type) Line 263   C++
    libcef.dll!aura::WindowEventDispatcher::DispatchMouseExitAtPoint(const gfx::Point & point) Line 156   C++
    libcef.dll!aura::WindowEventDispatcher::DispatchMouseExitToHidingWindow(aura::Window * window) Line 253   C++
    libcef.dll!aura::WindowEventDispatcher::OnWindowVisibilityChanging(aura::Window * window, bool visible) Line 602   C++
    libcef.dll!aura::Window::SetVisible(bool visible) Line 925   C++
    libcef.dll!aura::Window::Hide() Line 359   C++
    libcef.dll!views::NativeWidgetAura::Hide() Line 478   C++
    libcef.dll!views::Widget::Hide() Line 635   C++
    libcef.dll!views::TouchSelectionControllerImpl::EditingHandleView::SetWidgetVisible(bool visible, bool quick) Line 255   C++
    libcef.dll!views::TouchSelectionControllerImpl::HideHandles(bool quick) Line 429   C++
    libcef.dll!content::TouchEditableImplAura::EndTouchEditing(bool quick) Line 94   C++
    libcef.dll!content::TouchEditableImplAura::DestroyTouchSelection() Line 337   C++
    libcef.dll!views::TouchSelectionControllerImpl::OnMouseEvent(ui::MouseEvent * event) Line 541   C++
    libcef.dll!ui::EventHandler::OnEvent(ui::Event * event) Line 29   C++
    libcef.dll!ui::EventDispatcher::DispatchEvent(ui::EventHandler * handler, ui::Event * event) Line 190   C++
    libcef.dll!ui::EventDispatcher::DispatchEventToEventHandlers(std::vector<ui::EventHandler *,std::allocator<ui::EventHandler *> > * list, ui::Event * event) Line 170   C++
    libcef.dll!ui::EventDispatcher::ProcessEvent(ui::EventTarget * target, ui::Event * event) Line 127   C++
    libcef.dll!ui::EventDispatcherDelegate::DispatchEventToTarget(ui::EventTarget * target, ui::Event * event) Line 86   C++
    libcef.dll!ui::EventDispatcherDelegate::DispatchEvent(ui::EventTarget * target, ui::Event * event) Line 57   C++
    libcef.dll!aura::WindowEventDispatcher::DispatchMouseEnterOrExit(const ui::MouseEvent & event, ui::EventType type) Line 283   C++
    libcef.dll!aura::WindowEventDispatcher::DispatchMouseExitAtPoint(const gfx::Point & point) Line 156   C++
    libcef.dll!aura::WindowEventDispatcher::DispatchMouseExitToHidingWindow(aura::Window * window) Line 253   C++
    libcef.dll!aura::WindowEventDispatcher::OnWindowVisibilityChanging(aura::Window * window, bool visible) Line 602   C++
    libcef.dll!aura::Window::SetVisible(bool visible) Line 925   C++
    libcef.dll!aura::Window::Hide() Line 359   C++
    libcef.dll!views::NativeWidgetAura::Hide() Line 478   C++
    libcef.dll!views::Widget::Hide() Line 635   C++
    libcef.dll!views::TouchSelectionControllerImpl::EditingHandleView::SetWidgetVisible(bool visible, bool quick) Line 255   C++
    libcef.dll!views::TouchSelectionControllerImpl::HideHandles(bool quick) Line 429   C++
    libcef.dll!content::TouchEditableImplAura::EndTouchEditing(bool quick) Line 94   C++
    libcef.dll!content::TouchEditableImplAura::DestroyTouchSelection() Line 337   C++
    libcef.dll!views::TouchSelectionControllerImpl::OnMouseEvent(ui::MouseEvent * event) Line 541   C++
    libcef.dll!ui::EventHandler::OnEvent(ui::Event * event) Line 29   C++
    libcef.dll!ui::EventDispatcher::DispatchEvent(ui::EventHandler * handler, ui::Event * event) Line 190   C++
    libcef.dll!ui::EventDispatcher::DispatchEventToEventHandlers(std::vector<ui::EventHandler *,std::allocator<ui::EventHandler *> > * list, ui::Event * event) Line 170   C++
    libcef.dll!ui::EventDispatcher::ProcessEvent(ui::EventTarget * target, ui::Event * event) Line 127   C++
    libcef.dll!ui::EventDispatcherDelegate::DispatchEventToTarget(ui::EventTarget * target, ui::Event * event) Line 86   C++
    libcef.dll!ui::EventDispatcherDelegate::DispatchEvent(ui::EventTarget * target, ui::Event * event) Line 57   C++
...
...
    The maximum number of stack frames supported by Visual Studio has been exceeded.   


I have tested the client-app and the following versions seem to have the same problem: 2171, 2272 and 2357. While 2454 and 2494 do not.

If I could upgrade to the latest version I would, but as the "copy", "paste" etc. menu (which appears for text when using touch) looks really weird on them and that the tabtip (touch) keyboard in Windows doesn't automatically appear when using touch to select text fields, I'm stuck on earlier versions.

Please help. :/
FinitelyFailed
Techie
 
Posts: 27
Joined: Wed Sep 16, 2015 1:22 am

Re: Stack overflow, when using touch input.

Postby ddeas » Thu Oct 08, 2015 8:32 am

I was suffering with the exact same issue.

Assuming your not using CefSharp, this may or may not be any good to you, but CefSharps example form employs a slight hack to circumvent an unrelated issue (that appears to fix this one).

By intercepting WM_MOUSEACTIVATE messages to the browser control, and posting a WM_NLCBUTTONDOWN to the control's top level window handle, this issue appears to be prevented. Without knowing what environment your in, I don't know if that helps.

Code: Select all
private void OnIsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs args)
        {
            if (args.IsBrowserInitialized)
            {
                ChromeWidgetMessageInterceptor.SetupLoop(
                    (ChromiumWebBrowser)this.browserForm.Chromium,
                    (message) =>
                        {
                            const int WM_MOUSEACTIVATE = 0x0021;
                            const int WM_NCLBUTTONDOWN = 0x00A1;

                            if (message.Msg == WM_MOUSEACTIVATE)
                            {
                                // The default processing of WM_MOUSEACTIVATE results in MA_NOACTIVATE,
                                // and the subsequent mouse click is eaten by Chrome.
                                // This means any .NET ToolStrip or ContextMenuStrip does not get closed.
                                // By posting a WM_NCLBUTTONDOWN message to a harmless co-ordinate of the
                                // top-level window, we rely on the ToolStripManager's message handling
                                // to close any open dropdowns:
                                // http://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/ToolStripManager.cs,1249
                                var topLevelWindowHandle = message.WParam;
                                PostMessage(topLevelWindowHandle, WM_NCLBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
                            }
                        });
            }
        }
ddeas
Techie
 
Posts: 13
Joined: Thu Oct 08, 2015 8:20 am

Re: Stack overflow, when using touch input.

Postby FinitelyFailed » Thu Oct 08, 2015 9:31 am

Thanks for the replay, as you assumed I do not use cefsharp. I'm using C++, in Visual Studio 2013, building a x64 application. :/
FinitelyFailed
Techie
 
Posts: 27
Joined: Wed Sep 16, 2015 1:22 am

Re: Stack overflow, when using touch input.

Postby ddeas » Thu Oct 08, 2015 9:42 am

I would presume you could still implement that behaviour as a workaround?

Once your browser control activates/focuses, post a WM_NCLBUTTONDOWN message to the parent container simulating a mouse click? I have no idea why, but it has stopped the crash for me.
ddeas
Techie
 
Posts: 13
Joined: Thu Oct 08, 2015 8:20 am

Re: Stack overflow, when using touch input.

Postby FinitelyFailed » Thu Oct 08, 2015 10:13 am

Well, I may be able to implement it. If I would know where to start. I can't find a similar function to "OnIsBrowserInitializedChanged" in any of the C++ handlers (or similar). I have probably missed something ... I'm pretty new to CEF.

Doesn't the mouse event screw up the focus? E.g. if you are using the touch keyboard to edit a text-field, won't a mouse-click remove the focus or what actually happens? :P
FinitelyFailed
Techie
 
Posts: 27
Joined: Wed Sep 16, 2015 1:22 am

Re: Stack overflow, when using touch input.

Postby ddeas » Thu Oct 08, 2015 10:36 am

Well a WM_NLCBUTTONDOWN event is essentially a mouse click that occurs in a non-client area of a control/window (so not the main bit). And don't forget, this is only the windows message. There must be a low level handle on the control/form that reacts to this message in a way that changes some sort of state, but not enough to trigger a full focus action.

Anyway, you're not going to find the OnIsBrowserInitializedChanged event, that's specific to the CefSharp control. I've not done anything with the CEF library directly, but you must have a browser control on your form. You would need to hook into it's messaging loop (in .Net we can override a controls wndProc event, I don't know what your equivalent is), to intercept any WM_MOUSEACTIVATE [0x0021] messages (unless you have a .GotFocus event or something you can subscribe to). React to this by posting a WM_NCLBUTTONDOWN [0x00A1] message using user32.dll's PostMessage() API call to the top-most window handle your control belongs to (i.e. your form).

I'm sorry I cant be more help, but I was banging my head around for weeks over this issue, so I know there is no help online about it. This at least, once converted into C++, should help you.
ddeas
Techie
 
Posts: 13
Joined: Thu Oct 08, 2015 8:20 am

Re: Stack overflow, when using touch input.

Postby FinitelyFailed » Thu Oct 08, 2015 10:42 am

Thanks for all your help, I really appreciate it.

I will look into it tomorrow. And if I do find a solution I will try to post it here for any other lost soul.
FinitelyFailed
Techie
 
Posts: 27
Joined: Wed Sep 16, 2015 1:22 am

Re: Stack overflow, when using touch input.

Postby amaitland » Thu Oct 08, 2015 4:09 pm

Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: Stack overflow, when using touch input.

Postby ddeas » Fri Oct 09, 2015 3:43 am

Also, you mentioned that tabtip does not automatically show on the newer versions... that's not entirely accurate.
It doesn't show if you have a keyboard connected (as it doesn't need to). Once you undock from a keyboard, it will start to show. Which in my opinion, is much much better.
ddeas
Techie
 
Posts: 13
Joined: Thu Oct 08, 2015 8:20 am

Re: Stack overflow, when using touch input.

Postby FinitelyFailed » Fri Oct 09, 2015 4:37 am

As I have an update-loop running I figured that I would try to capture messages in that loop, using PeekMessage https://msdn.microsoft.com/en-us/library/windows/desktop/ms644943(v=vs.85).aspx. Using the hnwd that my browser uses. At the most I got one 512-messages which is WM_MOUSEFIRST/WM_MOUSEMOVE according to http://wiki.winehq.org/List_Of_Windows_Messages (no I didn't find what the messages means on MSDN, why do MS docs suck?) I can't find any other way to intercept messages ... So I am a bit stuck. :(

ddeas wrote:Also, you mentioned that tabtip does not automatically show on the newer versions... that's not entirely accurate.
It doesn't show if you have a keyboard connected (as it doesn't need to). Once you undock from a keyboard, it will start to show. Which in my opinion, is much much better.


Maybe, but it is quite annoying to have to disconnect/connect your keyboard during development. I wish there where more control when it comes to tabtip ... But the main problem is the weird menu that appears in the newer versions for copy, past etc. I want to remove the menu all together but that seems impossible.
Image
FinitelyFailed
Techie
 
Posts: 27
Joined: Wed Sep 16, 2015 1:22 am

Next

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 77 guests