Windowless windows not always windowless

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.

Re: Windowless windows not always windowless

Postby callum » Wed Mar 21, 2018 12:58 pm

I noticed when I trigger the issue and OnBeforePopup(..) is not called (just before a popup opens), I do get an OnBeforeBrowse event - perhaps if I can find a way to determine that continuing to browse will open the popup, I can return true and stop it.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Windowless windows not always windowless

Postby magreenblatt » Wed Mar 21, 2018 1:30 pm

Are you changing the CefLifeSpanHandler object returned by CefClient at any point after calling CreateBrowser?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Windowless windows not always windowless

Postby callum » Wed Mar 21, 2018 1:46 pm

I don't believe so - I tried breaking out the handler into its own LifeSpanHandler class and returning that in GetLifeSpanHandler() from CefClient:

Code: Select all
class LifeSpanHandler :
    public CefLifeSpanHandler
{
    public:
        bool 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) override
        {
            CEF_REQUIRE_UI_THREAD();

            std::cout << "Page wants to open a popup" << std::endl;

            return true;
        };

        void OnAfterCreated(CefRefPtr<CefBrowser> browser) override
        {
            CEF_REQUIRE_UI_THREAD();

            mBrowserList.push_back(browser);
        }

        void OnBeforeClose(CefRefPtr<CefBrowser> browser) override
        {
            CEF_REQUIRE_UI_THREAD();

            BrowserList::iterator bit = mBrowserList.begin();
            for (; bit != mBrowserList.end(); ++bit)
            {
                if ((*bit)->IsSame(browser))
                {
                    mBrowserList.erase(bit);
                    break;
                }
            }

            if (mBrowserList.empty())
            {
                gExitFlag = true;
            }
        }

        IMPLEMENT_REFCOUNTING(LifeSpanHandler);

    private:
        typedef std::list<CefRefPtr<CefBrowser>> BrowserList;
        BrowserList mBrowserList;
};
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Windowless windows not always windowless

Postby magreenblatt » Wed Mar 21, 2018 1:57 pm

magreenblatt wrote:I also modified cefclient at current master to return true from ClientHandler::OnBeforePopup, ran with `--off-screen-rendering-enabled --url=https://callum-linden.s3.amazonaws.com/bigclick.html` and manually clicked the link. However, no popup was created for me.

This should be reasonable way to try and reproduce your problem, or am I missing something? When I'm on Windows next I'll try it with the various message loop run modes that cefclient supports.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Windowless windows not always windowless

Postby callum » Wed Mar 21, 2018 2:07 pm

The important piece of the repro seems to be to start loading the 'big click' page while the first page (http://community.secondlife.com/t5/Feat ... ature_news) page is loading. If you try to start the load too quickly or after the first page is loaded, things work as expected. The window is pretty large - a second or two - and it helps to clear the cache.

I wasn't able to test in CefClient because (and this sounds odd), it refuses to start loading a new page until you hit stop or the current one is loaded so it never repro'd.

I'll try different starting pages and see if it's something with that page that is responsible.

Edit: As I expected, any page that takes a second or two to load and enable you to navigate to a new page before it completes triggers it. I used https://news.google.com for example.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Windowless windows not always windowless

Postby callum » Wed Mar 21, 2018 4:18 pm

I was able to get Debug configuration working again thanks to a post( http://magpcss.org/ceforum/viewtopic.php?f=6&t=14721) here on this forum that explained how you need to add a manifest file with Windows version compatibility UUIDs. Once the test app worked in Debug, I was able to trigger the repro and hit an assert (I think). I grabbed the libcef.dll.pdb from the Spotify site and got a stack trace:

Code: Select all
    libcef.dll!base::debug::BreakDebugger() Line 21   C++
    libcef.dll!logging::LogMessage::~LogMessage() Line 842   C++
    libcef.dll!CefLifeSpanHandlerCToCpp::OnBeforePopup(scoped_refptr<CefBrowser> browser, scoped_refptr<CefFrame> frame, const CefStringBase<CefStringTraitsUTF16> & target_url, const CefStringBase<CefStringTraitsUTF16> & target_frame_name, <unnamed-tag> target_disposition, bool user_gesture, const CefStructBase<CefPopupFeaturesTraits> & popupFeatures, CefWindowInfo & windowInfo, scoped_refptr<CefClient> & client, CefStructBase<CefBrowserSettingsTraits> & settings, bool * no_javascript_access) Line 45   C++
    libcef.dll!CefBrowserInfoManager::CanCreateWindow(content::RenderFrameHost * opener, const GURL & target_url, const content::Referrer & referrer, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & frame_name, WindowOpenDisposition disposition, const blink::mojom::WindowFeatures & features, bool user_gesture, bool opener_suppressed, bool * no_javascript_access) Line 189   C++
    libcef.dll!CefContentBrowserClient::CanCreateWindow(content::RenderFrameHost * opener, const GURL & opener_url, const GURL & opener_top_level_frame_url, const GURL & source_origin, content::mojom::WindowContainerType container_type, const GURL & target_url, const content::Referrer & referrer, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & frame_name, WindowOpenDisposition disposition, const blink::mojom::WindowFeatures & features, bool user_gesture, bool opener_suppressed, bool * no_javascript_access) Line 886   C++
    libcef.dll!content::RenderFrameHostImpl::CreateNewWindow(mojo::StructPtr<content::mojom::CreateNewWindowParams> params, base::OnceCallback<void (content::mojom::CreateNewWindowStatus, mojo::StructPtr<content::mojom::CreateNewWindowReply>)> callback) Line 2893   C++
    libcef.dll!content::mojom::FrameHostStubDispatch::AcceptWithResponder(content::mojom::FrameHost * impl, mojo::Message * message, std::unique_ptr<mojo::MessageReceiverWithStatus,std::default_delete<mojo::MessageReceiverWithStatus> > responder) Line 2585   C++
    libcef.dll!content::mojom::FrameHostStub<mojo::RawPtrImplRefTraits<content::mojom::FrameHost> >::AcceptWithResponder(mojo::Message * message, std::unique_ptr<mojo::MessageReceiverWithStatus,std::default_delete<mojo::MessageReceiverWithStatus> > responder) Line 812   C++
    libcef.dll!mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message * message) Line 394   C++
    libcef.dll!mojo::FilterChain::Accept(mojo::Message * message) Line 40   C++
    libcef.dll!mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message * message) Line 306   C++
    libcef.dll!IPC::`anonymous namespace'::ChannelAssociatedGroupController::AcceptSyncMessage(unsigned int interface_id, unsigned int message_id) Line 821   C++
    libcef.dll!base::debug::TaskAnnotator::RunTask(const char * queue_function, base::PendingTask * pending_task) Line 53   C++
    libcef.dll!base::internal::IncomingTaskQueue::RunTask(base::PendingTask * pending_task) Line 124   C++
    libcef.dll!base::MessageLoop::RunTask(base::PendingTask * pending_task) Line 399   C++
    libcef.dll!base::MessageLoop::DeferOrRunPendingTask(base::PendingTask pending_task) Line 411   C++
    libcef.dll!base::MessageLoop::DoWork() Line 455   C++
    libcef.dll!base::MessagePumpForUI::DoRunLoop() Line 174   C++
    libcef.dll!base::MessagePumpWin::Run(base::MessagePump::Delegate * delegate) Line 58   C++
    libcef.dll!base::MessageLoop::Run(bool application_tasks_allowed) Line 352   C++
    libcef.dll!base::RunLoop::Run() Line 133   C++
    libcef.dll!base::RunLoop::RunUntilIdle() Line 143   C++
    libcef.dll!CefBrowserMessageLoop::DoMessageLoopIteration() Line 117   C++
>   cef_opengl_win.exe!CefDoMessageLoopWork() Line 397   C++
    cef_opengl_win.exe!cefImpl::update() Line 344   C++
    cef_opengl_win.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 654   C++


To look at parameters for each line of call stack I need to grab the relevant source code - looking at that now but in the meantime, maybe something rings a bell here?
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Windowless windows not always windowless

Postby magreenblatt » Wed Mar 21, 2018 5:15 pm

The output should also tell you which DCHECK failed. If the line numbers are correct it looks like this one: https://bitbucket.org/chromiumembedded/ ... ocpp.cc-45. So the frame appears to be NULL which explains why you're not getting the OnBeforePopup callback. You should debug in CefBrowserInfoManager::CanCreateWindow to determine why the frame is NULL.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Windowless windows not always windowless

Postby callum » Mon Mar 26, 2018 2:17 pm

I wasn't able to figure it out but I did find this post from 18 months ago that I think is relevant. Unfortunately, I'm not able to build CEF locally (version of Visual Studio is too old) so I think I'm at a dead end.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Windowless windows not always windowless

Postby magreenblatt » Mon Mar 26, 2018 2:39 pm

This sounds like a bug that will take some effort to fix reliably (write a unit test, etc). I think all of the necessary clues are included in this thread. Since this is important to you, and you've already invested time, you might want to follow through by building CEF/Chromium locally and developing a PR to fix the issue.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Windowless windows not always windowless

Postby callum » Mon Mar 26, 2018 3:17 pm

Understood - I think it's time to try to build CEF/Chromium locally too. My understanding (and limited experience of) is that multiple versions of Visual Studio don't exist side-by-side very well - certainly the older ones like we are using - so I'll see about finding another box to install VS 2015 or VS2017 on and see where I get to.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Previous

Return to Support Forum

Who is online

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