Error on start, how to close and change name

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.

Error on start, how to close and change name

Postby dmklementiev » Tue Oct 29, 2019 1:06 pm

Hello, just wanted to mention that I've implemented oauth2 authorization code flow with CEF and it works perfectly. Thank you Marshall and Czarek for your help.

I still have three relatively minor questions. Please let me know if it would be more appropriate to create separate topics for each of them.

Q1. Sometimes when I start cefsimple I am getting the following error
Trace/breakpoint trap
[1028/094702.514588:FATAL:x11_window.cc(543)] Check failed: !has_window_focus_ || !has_pointer_focus_.

Is this known? What would be the proper way to deal with this issue?

Q2. How to close CEF properly? I am getting authorization code in CefResourceRequestHandler::OnResourceLoadComplete() and at this point I don't need the browser anymore so want to close it. I've tried bool SimpleHandler::DoClose(CefRefPtr<CefBrowser> browser) and void SimpleHandler::CloseAllBrowsers(bool force_close) but in both cases I am getting SIGTRAP, so what would be the right way to close CEF?

Q3. Is it possible to change name of cefsimple? When I try to do this in my CMakeList file I am getting SIGTRAP with the following callstack:

Code: Select all
1  LoadV8NativesFromFile               v8_initializer.cc           367 0x7fb5d225f4
2  gin::V8Initializer::LoadV8Natives() v8_initializer.cc           330 0x7fb5d224c0
3  LoadV8NativesFile                   content_main_runner_impl.cc 238 0x7fb262c8cc
4  InitializeV8IfNeeded                content_main_runner_impl.cc 250 0x7fb262c8cc
5  Initialize                          content_main_runner_impl.cc 761 0x7fb262c8cc
6  MainInitialize                      main.cc                     376 0x7fb444ba2c
7  Initialize                          context.cc                  418 0x7fb2853374
8  CefInitialize                       context.cc                  251 0x7fb2853048
9  cef_initialize                      libcef_dll.cc               112 0x7faf7b938c
10 CefInitialize                       libcef_dll_wrapper.cc       105 0x55555bbefc
11 main   


And final question: How do I open an issue for CEF. Czarec recommended me to open a bug in this thread https://magpcss.org/ceforum/viewtopic.php?f=6&t=17121, so I'd like to do this.

void SimpleHandler::CloseAllBrowsers(bool force_close)
dmklementiev
Mentor
 
Posts: 54
Joined: Wed Jul 31, 2019 7:11 pm

Re: Error on start, how to close and change name

Postby Czarek » Tue Nov 05, 2019 4:31 am

Q1. Does the issue occur in original unmodified cefsimple app?
Q2. OnResourceLoadComplete is called on IO thread. I suggest you close the browser outside of any handler callbacks using CefPostTask function.
Q3. Replace all occurences of "cefsimple" in all files.
Marshall already replied to you in one of the topics.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Error on start, how to close and change name

Postby dmklementiev » Tue Nov 26, 2019 2:40 pm

Hi Czarek,

Sorry for the delayed response. Was out of town, missed your reply and was experimenting just by myself. Answers to your questions (and thank you in advance for your answers : )

Q1. Yes it does. Here is the output

Code: Select all
./cefsimple -url=https://login.microsoftonline.com/microsoft.onmicrosoft.com/oauth2/v2.0/authorize?response_type=code&scope=https%3A%2F%2Fgraph.microsoft.com%2Fcalendars.read%20 offline_access&client_id=***&redirect_uri=http://localhost
[1] 30987
[2] 30988
bash: offline_access: command not found
[3] 30989
[2]-  Exit 127                scope=https%3A%2F%2Fgraph.microsoft.com%2Fcalendars.read%20 offline_access
dmitri@dmitri-jetson:/media/dmitri/DATA$ [1122/124234.711763:INFO:content_main_runner_impl.cc(943)] Chrome is running in full browser mode.
[1122/124235.127899:FATAL:x11_window.cc(543)] Check failed: !has_window_focus_ || !has_pointer_focus_.


Q2. I tried to call CloseAllBrowsers from cefsimple

Code: Select all
void ClientHandler::CloseAllBrowsers(bool force_close)
{
    if (!CefCurrentlyOn(TID_UI))
    {
        // Execute on the UI thread.
        CefPostTask(TID_UI, base::Bind(&ClientHandler::CloseAllBrowsers, this,
                                       force_close));
        return;
    }
    if (browser_list_.empty())
        return;
    BrowserList::const_iterator it = browser_list_.begin();
    for (; it != browser_list_.end(); ++it)
        (*it)->GetHost()->CloseBrowser(force_close);
}


from CefResourceRequestHandler::OnResourceLoadComplete(). Seems that it does what you suggested - call on UI thread (if I understood your correctly). Still fails but with more definite error

Code: Select all
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 20 (X_GetProperty)
Resource id in failed request: 0x3400002
Serial number of failed request: 2358
Current serial number in output stream: 2358
[1126/112759.267631:FATAL:context.cc(58)] Check failed: !g_context. CefShutdown was not called


Tried to call CefShutdown() from multiple places - still SIGTRAP. So just was wondering how this is done properly?

CefResourceRequestHandler::OnResourceLoadComplete()

Q3. I've replaced all occurences of "cefsimple" in all files in my project - getting the error mentioned below. I've tried to change the name in CEF codebase, but without much success so far. Will keep trying, but if you could suggest list of files where the change should be made that would be great.

Really appreciate your help.
Dmitri
dmklementiev
Mentor
 
Posts: 54
Joined: Wed Jul 31, 2019 7:11 pm

Re: Error on start, how to close and change name

Postby janko » Wed Nov 27, 2019 7:23 am

I have the same problem - Q1 on linux
> Q1. Sometimes when I start cefsimple I am getting the following error
> Trace/breakpoint trap
> [1028/094702.514588:FATAL:x11_window.cc(543)] Check failed: !has_window_focus_ || !has_pointer_focus_.

I investigate this problem and I found out that this is connected with execute cefsimple from terminal - (no depend of terminal program I use 3 different - always the same). On Linux Mint when I made desktop shortcut and execute cefsimple from Icon Shortcut this problem not exists, but from terminal it failure sometimes ones per 3-4 executes sometimes many exectues without problem, sometime when one failure then next few will be failure to - after terminal restart will be ok.
i test it on: ./cefsimple --url=https://parall.ax/products/jspdf

Czarek - It looks like that, when it is executed from terminal and some scripts to load (or some resources) it is not on time to get/swich focus from terminal to cef.
(with local text file is always ok --url=file://home/user/test.txt, but with local file with scripts --url=file://home/user/htmldoc_with_scripts.html sometime failure)
(Test on: Linux Mint 19.2 - i7-2640m, SSD)

Pozdrawiam
janko
Techie
 
Posts: 13
Joined: Wed Nov 27, 2019 6:26 am

Re: Error on start, how to close and change name

Postby Czarek » Wed Nov 27, 2019 10:16 am

@dmklementiev

It looks like your terminal doesn't pass the complete url to cefsimple, but instead executes some of it. You have a space there.

What Linux distribution are you running?

Q2 -> Maybe try use CefPostDelayedTask. It is tricky to close browser during request from request handler callbacks.

The cefsimple example already calls CefShutdown.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Error on start, how to close and change name

Postby dmklementiev » Wed Nov 27, 2019 2:48 pm

Czarek,

On white space. I guess you are talking about space in "scope=https%3A%2F%2Fgraph.microsoft.com%2Fcalendars.read%20 offline_access". offline_access is part of scope parameters that are divided by space - https://docs.microsoft.com/bs-cyrl-ba/a ... ess-tokens. If I am correct I think everything is good here.

The way the error happens is the same as janko described in the post above.

Q2-> I've replaced CefPostTask with CefPostDelayedTask in void ClientHandler::CloseAllBrowsers(bool force_close) mentioned above with delay 10 secs - same result.

Any ideas are highly appreciated.
dmklementiev
Mentor
 
Posts: 54
Joined: Wed Jul 31, 2019 7:11 pm

Re: Error on start, how to close and change name

Postby Czarek » Wed Nov 27, 2019 3:20 pm

From what I see CloseAllBrowsers is only being called on Mac in cefsimple example. On Windows when you close/destroy window the browsers are automatically closed. On Linux since you depend on CEF creating the X11 window internally, try send the WM_DELETE_WINDOW event message. See here: https://github.com/chromiumembedded/cef ... 11.cc#L155

You have a space on command line, thus the url passed to cefsimple is incomplete.

Since the name "cefsimple" is unique, replacing it in all files with other name should do the job. Use other tool to find all occurences of "cefsimple" in files.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Error on start, how to close and change name

Postby janko » Wed Nov 27, 2019 3:44 pm

Czarek

Space is in address but it not cause - Q1. problem. I load dmklementiev url on my computer - and with space it only load not proper address, but load, with --url with double quote load good address, but it some times failure too. Please read my earlier post - it is some deeper investigation in this problem
janko
Techie
 
Posts: 13
Joined: Wed Nov 27, 2019 6:26 am

Re: Error on start, how to close and change name

Postby Czarek » Wed Nov 27, 2019 11:58 pm

The error occurs in Chromium: https://cs.chromium.org/chromium/src/ui ... &g=0&l=562

You can ask on Chromium discussion group or report a bug in Chromium. But seems to me it's a bug in your Linux distribution. Try running on a clean Linux system. Remove any terminal addons etc.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Error on start, how to close and change name

Postby janko » Thu Nov 28, 2019 8:01 am

Czarek
My first test env was: i7-2640m, SSD, 8ram - Linux Mint 64bit 19.2 Xfce - latest updates.
Now I made few tests:
I made clean Linux Mint - Xfce 64bit 19.2=(Ubuntu) 18.04 in VMware and download clean cef from spotify v108 and problem still exist.
I made clean Linux Mint -Cinnamon 64bit 19.2=(Ubunt 18.04) in VMware and download clean cef from spotify v108 and problem still exist.
I made clean Ubuntu 19.10 64bit in VMware and download clean cef from spotify v108 and problem still exists.
My procedure - install system, install prerequesties for compile, install ninja lastest binaries, and then cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug, ninja cefsimple
Then ./cefsimple --url=https://parall.ax/products/jspdf - execute, close, execute, close... - and on Ubuntu 19.10 it failure on second try.

After test: It is not depend on terminal software, It is not depend on Window Manager, It is not depenend on Kernel version.
On my main machine I have installed chromium-browser on the same core version v108 as cef, chromium-browser work without any probem, but cefsimple have problem.
It look like Chromium Browser as bigger soft make more things before initialize window, but cefsimple make it too fast or something similar.
janko
Techie
 
Posts: 13
Joined: Wed Nov 27, 2019 6:26 am

Next

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 10 guests