After return true in OnBeforePopup, it still pops up

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.

After return true in OnBeforePopup, it still pops up

Postby slothsimon » Sun Mar 19, 2017 11:37 pm

Hi,

CEF version: Branch 2623 win32
OS: Windows 7 64bit

I embedded cef in my main application. To make all pages loaded in one browser I return true in OnBeforePopup functions. But when I clicked a https link and before OnLoadStart called I clicked another or the same link again, my program will generate a new unexpected window. This is my OnBeforePopup function:
Code: Select all
bool BrowserHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
                           CefRefPtr<CefFrame> frame,
                           const CefString& target_url,
                           const CefString& target_frame_name,
                           CefLifeSpanHandler::WindowOpenDisposition target_disposition,
                           bool user_gesture,
                           const CefPopupFeatures& popupFeatures,
                           CefWindowInfo& windowInfo,
                           CefRefPtr<CefClient>& client,
                           CefBrowserSettings& settings,
                           bool* no_javascript_access){
                              CEF_REQUIRE_IO_THREAD();
                              browser->GetMainFrame()->LoadURL(target_url);
                              return true;
}


The output log say in life_span_handler_ctocpp.cc Line 39 check failed which is in CefLifeSpanHandlerCToCpp::OnBeforePopup funciton:
Code: Select all
  DCHECK(frame.get());
  if (!frame.get())
    return false;


The first click will call my custom OnBeforePopup, but the second click will not call it. Instead it will return false in CefLifeSpanHandlerCToCpp::OnBeforePopup. I guess that's why new popup generated. But why the frame pointer will be empty? That's strange...Maybe LoadURL function will destroy the old frame???

How to solve it?
slothsimon
Newbie
 
Posts: 9
Joined: Wed Feb 08, 2017 8:44 pm

Re: After return true in OnBeforePopup, it still pops up

Postby slothsimon » Sun Mar 26, 2017 9:08 pm

Modified the description, now it is more accurate and specific. Hope some one can help me :?
slothsimon
Newbie
 
Posts: 9
Joined: Wed Feb 08, 2017 8:44 pm

Re: After return true in OnBeforePopup, it still pops up

Postby HarmlessDave » Mon Mar 27, 2017 11:44 am

But when I clicked a https link and before OnLoadStart called I clicked another or the same link again, my program will generate a new unexpected window.


So you click again before the first click has had a chance to replace the page with the new popup page?

Maybe you're doing this at a point when there is no valid frame -- the old one is being / has been destroyed, the new one has not replaced it yet. You could try checking that GetMainFrame returned a valid frame and if not then just discard the click: skip the LoadURL, still return true.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: After return true in OnBeforePopup, it still pops up

Postby slothsimon » Tue Mar 28, 2017 1:40 am

HarmlessDave wrote:So you click again before the first click has had a chance to replace the page with the new popup page?

Yes, because the https URL spends a long time to get response.

HarmlessDave wrote:Maybe you're doing this at a point when there is no valid frame -- the old one is being / has been destroyed, the new one has not replaced it yet. You could try checking that GetMainFrame returned a valid frame and if not then just discard the click: skip the LoadURL, still return true.

I've tried, but the second click even doesn't call my custum OnBeforePopup: it throws DCHECK(frame.get()) error before that.

Anyway, thank you for advice!:) I now use a bool variable to control the sending of mouse click events. In my custom OnBeforePopup, I set the variable to true while in my custum OnLoadStart I set the variable to false. And when the variable is true, I will not send mouse click events to cef so that it will not call life_span_handler_ctocpp.OnBeforePopup which throw DCHECK errors.

Is this designed or just a bug?
slothsimon
Newbie
 
Posts: 9
Joined: Wed Feb 08, 2017 8:44 pm

Re: After return true in OnBeforePopup, it still pops up

Postby magreenblatt » Tue Mar 28, 2017 11:33 am

2623 branch is quite old. It's likely a bug that is already fixed in newer branches.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: After return true in OnBeforePopup, it still pops up

Postby slothsimon » Tue Apr 04, 2017 10:53 pm

Hi,

I've tried the newest version on opensource.spotify.com: cef_binary_3.2987.1597.gffc5773_windows32

I make cefclient return true when calling OnBeforePopup, but it still has the same problem as above. :(
slothsimon
Newbie
 
Posts: 9
Joined: Wed Feb 08, 2017 8:44 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 37 guests