OnBeforeResourceLoad not called for some XHRs

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: OnBeforeResourceLoad not called for some XHRs

Postby rado » Sun Oct 15, 2023 1:32 pm

The call is inside of the create.bat
Code: Select all
set GN_DEFINES=is_component_build=true
set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*
call cef_create_projects.bat

But it is located in C:\code\chromium_git\chromium\src\cef while cef_create_projects.bat is located in C:\code\chromium_git\cef\cef_create_projects.bat so it cannot find it.
I've tried to remove the "call", provide full path to cef_create_projects.bat, run it from various directories, run cef_create_projects.bat directly outside create.bat and nothing works.
In last line it looks like it is looking to wrong directory
Code: Select all
C:\code\chromium_git\cef>set GN_DEFINES=is_component_build=true

C:\code\chromium_git\cef>set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*

C:\code\chromium_git\cef>cef_create_projects.bat

Generating CEF version header file...
Traceback (most recent call last):
  File "C:\code\chromium_git\cef\tools\make_version_header.py", line 109, in <module>
    main(sys.argv)
  File "C:\code\chromium_git\cef\tools\make_version_header.py", line 105, in main
    write_version_header(argv[1])
  File "C:\code\chromium_git\cef\tools\make_version_header.py", line 97, in write_version_header
    result = make_version_header(output)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\code\chromium_git\cef\tools\make_version_header.py", line 78, in make_version_header
    result = result.replace('$VERSION$', formatter.get_version_string())
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\code\chromium_git\cef\tools\cef_version.py", line 221, in get_version_string
    return self._get_version_string()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\code\chromium_git\cef\tools\cef_version.py", line 206, in _get_version_string
    self._compute_version()
  File "C:\code\chromium_git\cef\tools\cef_version.py", line 170, in _compute_version
    chrome_version = self.get_chrome_version_components()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\code\chromium_git\cef\tools\cef_version.py", line 48, in get_chrome_version_components
    assert os.path.isfile(file_path), file_path
AssertionError: C:\code\chromium_git\chrome\VERSION
Traceback (most recent call last):
  File "C:\code\chromium_git\cef\tools\gclient_hook.py", line 33, in <module>
    RunAction(cef_dir, cmd)
  File "C:\code\chromium_git\cef\tools\gclient_util.py", line 35, in RunAction
    gclient_utils.CheckCallAndFilter(
  File "c:\code\depot_tools\gclient_utils.py", line 715, in CheckCallAndFilter
    raise subprocess2.CalledProcessError(
subprocess2.CalledProcessError: Command 'C:\\Python311\\python.exe tools/make_version_header.py include/cef_version.h' returned non-zero exit status 1 in C:\code\chromium_git\cef
Traceback (most recent call last):

  File "C:\code\chromium_git\cef\tools\make_version_header.py", line 109, in <module>

    main(sys.argv)

  File "C:\code\chromium_git\cef\tools\make_version_header.py", line 105, in main

    write_version_header(argv[1])

  File "C:\code\chromium_git\cef\tools\make_version_header.py", line 97, in write_version_header

    result = make_version_header(output)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\code\chromium_git\cef\tools\make_version_header.py", line 78, in make_version_header

    result = result.replace('$VERSION$', formatter.get_version_string())

                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\code\chromium_git\cef\tools\cef_version.py", line 221, in get_version_string

    return self._get_version_string()

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\code\chromium_git\cef\tools\cef_version.py", line 206, in _get_version_string

    self._compute_version()

  File "C:\code\chromium_git\cef\tools\cef_version.py", line 170, in _compute_version

    chrome_version = self.get_chrome_version_components()

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\code\chromium_git\cef\tools\cef_version.py", line 48, in get_chrome_version_components

    assert os.path.isfile(file_path), file_path

AssertionError: C:\code\chromium_git\chrome\VERSION

rado
Expert
 
Posts: 145
Joined: Wed Oct 05, 2011 3:32 am

Re: OnBeforeResourceLoad not called for some XHRs

Postby magreenblatt » Sun Oct 15, 2023 8:30 pm

You need to call it inside the “chromium\src\cef” directory.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: OnBeforeResourceLoad not called for some XHRs

Postby rado » Mon Oct 16, 2023 9:51 am

It does this:
Code: Select all
C:\code\chromium_git\chromium\src\cef>C:\code\chromium_git\cef\cef_create_projects.bat
C:\Python311\python.exe: can't open file 'C:\\code\\chromium_git\\chromium\\src\\cef\\tools\\gclient_hook.py': [Errno 2] No such file or directory
rado
Expert
 
Posts: 145
Joined: Wed Oct 05, 2011 3:32 am

Re: OnBeforeResourceLoad not called for some XHRs

Postby magreenblatt » Mon Oct 16, 2023 9:58 am

What are the contents of your "C:\code\chromium_git\chromium\src\cef" directory?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: OnBeforeResourceLoad not called for some XHRs

Postby rado » Mon Oct 16, 2023 10:39 am

there is only create.bat which I've created in step 7 (I've also created the cef derectory because it didn't exist). Did I miss some step? Could be a problem that when I've run update.bat for the first time it stopped because of full disk and I've run it again after making more disk space? But I think it deleted previously downloaded chromium sources and started download from beginning.
rado
Expert
 
Posts: 145
Joined: Wed Oct 05, 2011 3:32 am

Re: OnBeforeResourceLoad not called for some XHRs

Postby magreenblatt » Mon Oct 16, 2023 11:18 am

Did I miss some step?

Yes. The contents of "C:\code\chromium_git\chromium\src\cef" should be the same as ""C:\code\chromium_git\chromium\cef" (you can copy the directory manually). Run all scripts from inside the "C:\code\chromium_git\chromium\src\cef" directory.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: OnBeforeResourceLoad not called for some XHRs

Postby rado » Mon Oct 16, 2023 12:27 pm

It seems the script did not resume correctly after low disk space interruption. I've got some error it did not find the rust version, so I've run update_rust, it helped but now it ended with this error
Code: Select all
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\code\\chromium_git\\chromium\\src\\build\\util\\LASTCHANGE'
                                           ERROR at //chrome/version.gni:116:11: Script returned non-zero exit code.
  _result = exec_script("//build/util/version.py",                                                                                                                              ^----------                                                                                                                                               Current dir: C:/code/chromium_git/chromium/src/out/Debug_GN_x64/
       Command: C:/Users/Rado/AppData/Local/Microsoft/WindowsApps/python3.exe C:/code/chromium_git/chromium/src/build/util/version.py -f ../../chrome/VERSION
-t "full = \"@MAJOR@.@MINOR@.@BUILD@.@PATCH@\" major = \"@MAJOR@\" minor = \"@MINOR@\" build = \"@BUILD@\" patch = \"@PATCH@\" " --os win                                 
      Returned 1.     


But at least it seems the patches were applied, so I'm fine with that. Unluckily it is still not possible to place breakpoints at some lines even in debug build, but I'll try.
dbg.png
dbg.png (60.44 KiB) Viewed 9637 times
rado
Expert
 
Posts: 145
Joined: Wed Oct 05, 2011 3:32 am

Re: OnBeforeResourceLoad not called for some XHRs

Postby rado » Mon Oct 16, 2023 4:32 pm

I'm afraid it looks like it requires somebody more experienced. This is what I've found so far:
I've logged places where the handlers are registered/removed and queried and other interesting places. It seems some service worker's requests are called from frame for which registration of the handler never happened.
The log immediately from start of the cefclient looks like this

Code: Select all
23:15:36:740   [1016/231536.592:WARNING:policy_logger.cc(148)] :components\enterprise\browser\controller\chrome_browser_cloud_management_controller.cc(88) Could not create policy manager as CBCM is not enabled.
23:15:51:410   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 5
23:15:51:522   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 5
23:15:53:818   content::NavigationControllerImpl::NavigateWithoutEntry(const content::NavigationController::LoadURLParams &)
23:15:53:818   content::RenderFrameHostImpl::RenderFrameCreated(void) child_id = 5
23:15:55:427   content::RenderFrameHostImpl::RenderFrameCreated(void) child_id = 6
23:15:55:531   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 6
23:15:55:787   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 6
23:15:55:787   CefRequestContextHandlerMap::RemoveHandler(const content::GlobalRenderFrameHostId &): global_id.child_id = 5
23:15:56:036   CefRequestContextHandlerMap::RemoveHandler(const content::GlobalRenderFrameHostId &): global_id.child_id = 5
23:15:58:289   content::RenderFrameHostImpl::CreateChildFrame(int, mojo::PendingAssociatedRemote<content::mojom::Frame>, mojo::PendingReceiver<blink::mojom::BrowserInterfaceBroker>, mojo::StructPtr<blink::mojom::PolicyContainerBindParams>, mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterfaceProvider>, blink::mojom::TreeScopeType, const std::__Cr::basic_string<char,std::__Cr::char_traits<char>,std::__Cr::allocator<char>> &, const std::__Cr::basic_string<char,std::__Cr::char_traits<char>,std::__Cr::allocator<char>> &, bool, const blink::FramePolicy &, mojo::StructPtr<blink::mojom::FrameOwnerProperties>, blink::FrameOwnerElementType, __int64) child_id = 6
23:15:58:289   content::RenderFrameHostImpl::RenderFrameCreated(void) child_id = 6
23:15:58:537   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 6
23:15:58:537   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 6
23:15:58:797   content::RenderFrameHostImpl::CreateChildFrame(int, mojo::PendingAssociatedRemote<content::mojom::Frame>, mojo::PendingReceiver<blink::mojom::BrowserInterfaceBroker>, mojo::StructPtr<blink::mojom::PolicyContainerBindParams>, mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterfaceProvider>, blink::mojom::TreeScopeType, const std::__Cr::basic_string<char,std::__Cr::char_traits<char>,std::__Cr::allocator<char>> &, const std::__Cr::basic_string<char,std::__Cr::char_traits<char>,std::__Cr::allocator<char>> &, bool, const blink::FramePolicy &, mojo::StructPtr<blink::mojom::FrameOwnerProperties>, blink::FrameOwnerElementType, __int64) child_id = 6
23:15:58:797   content::RenderFrameHostImpl::RenderFrameCreated(void) child_id = 6
23:15:59:041   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 6
23:15:59:041   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 6
23:15:59:041   content::Navigator::OnBeginNavigation(content::FrameTreeNode *, mojo::StructPtr<blink::mojom::CommonNavigationParams>, mojo::StructPtr<blink::mojom::BeginNavigationParams>, scoped_refptr<network::SharedURLLoaderFactory>, mojo::PendingAssociatedRemote<content::mojom::NavigationClient>, scoped_refptr<content::PrefetchedSignedExchangeCache>, int, mojo::PendingReceiver<content::mojom::NavigationRendererCancellationListener>)
23:15:59:325   content::RenderFrameHostImpl::RenderFrameCreated(void) child_id = 7
23:15:59:325   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 7
23:15:59:325   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 7
23:15:59:545   [1016/231559.328:WARNING:browser_info.cc(309)] Returning a speculative frame for 30064771078 [7,6]
23:15:59:545   content::Navigator::OnBeginNavigation(content::FrameTreeNode *, mojo::StructPtr<blink::mojom::CommonNavigationParams>, mojo::StructPtr<blink::mojom::BeginNavigationParams>, scoped_refptr<network::SharedURLLoaderFactory>, mojo::PendingAssociatedRemote<content::mojom::NavigationClient>, scoped_refptr<content::PrefetchedSignedExchangeCache>, int, mojo::PendingReceiver<content::mojom::NavigationRendererCancellationListener>)
23:15:59:545   content::RenderFrameHostImpl::CreateChildFrame(int, mojo::PendingAssociatedRemote<content::mojom::Frame>, mojo::PendingReceiver<blink::mojom::BrowserInterfaceBroker>, mojo::StructPtr<blink::mojom::PolicyContainerBindParams>, mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterfaceProvider>, blink::mojom::TreeScopeType, const std::__Cr::basic_string<char,std::__Cr::char_traits<char>,std::__Cr::allocator<char>> &, const std::__Cr::basic_string<char,std::__Cr::char_traits<char>,std::__Cr::allocator<char>> &, bool, const blink::FramePolicy &, mojo::StructPtr<blink::mojom::FrameOwnerProperties>, blink::FrameOwnerElementType, __int64) child_id = 6
23:15:59:815   content::RenderFrameHostImpl::RenderFrameCreated(void) child_id = 6
23:15:59:815   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 6
23:15:59:815   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 6
23:16:00:102   content::Navigator::OnBeginNavigation(content::FrameTreeNode *, mojo::StructPtr<blink::mojom::CommonNavigationParams>, mojo::StructPtr<blink::mojom::BeginNavigationParams>, scoped_refptr<network::SharedURLLoaderFactory>, mojo::PendingAssociatedRemote<content::mojom::NavigationClient>, scoped_refptr<content::PrefetchedSignedExchangeCache>, int, mojo::PendingReceiver<content::mojom::NavigationRendererCancellationListener>)
23:16:00:102   content::RenderFrameHostImpl::RenderFrameCreated(void) child_id = 7
23:16:00:102   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 7
23:16:00:288   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 7
23:16:00:288   content::Navigator::OnBeginNavigation(content::FrameTreeNode *, mojo::StructPtr<blink::mojom::CommonNavigationParams>, mojo::StructPtr<blink::mojom::BeginNavigationParams>, scoped_refptr<network::SharedURLLoaderFactory>, mojo::PendingAssociatedRemote<content::mojom::NavigationClient>, scoped_refptr<content::PrefetchedSignedExchangeCache>, int, mojo::PendingReceiver<content::mojom::NavigationRendererCancellationListener>)
23:16:00:547   CefRequestContextHandlerMap::GetHandler(const content::GlobalRenderFrameHostId &, bool): global_id.child_id = -1
23:16:00:547   [1016/231600.498:ERROR:cert_issuer_source_aia.cc(36)] Error parsing cert retrieved from AIA (as DER):
23:16:00:547   ERROR: Couldn't read tbsCertificate as SEQUENCE
23:16:00:547   ERROR: Failed parsing Certificate
23:16:00:547   
23:16:00:790   CefRequestContextHandlerMap::GetHandler(const content::GlobalRenderFrameHostId &, bool): global_id.child_id = 8
23:16:01:041   content::RenderFrameHostImpl::CreateChildFrame(int, mojo::PendingAssociatedRemote<content::mojom::Frame>, mojo::PendingReceiver<blink::mojom::BrowserInterfaceBroker>, mojo::StructPtr<blink::mojom::PolicyContainerBindParams>, mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterfaceProvider>, blink::mojom::TreeScopeType, const std::__Cr::basic_string<char,std::__Cr::char_traits<char>,std::__Cr::allocator<char>> &, const std::__Cr::basic_string<char,std::__Cr::char_traits<char>,std::__Cr::allocator<char>> &, bool, const blink::FramePolicy &, mojo::StructPtr<blink::mojom::FrameOwnerProperties>, blink::FrameOwnerElementType, __int64) child_id = 6
23:16:01:041   content::RenderFrameHostImpl::RenderFrameCreated(void) child_id = 6
23:16:01:292   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 6
23:16:01:292   CefRequestContextHandlerMap::AddHandler(const content::GlobalRenderFrameHostId &, scoped_refptr<CefRequestContextHandler>): global_id.child_id = 6
23:16:01:292   [1016/231601.214:WARNING:browser_info.cc(309)] Returning a speculative frame for 30064771081 [7,9]
23:16:01:292   [1016/231601.215:WARNING:browser_info.cc(309)] Returning a speculative frame for 30064771081 [7,9]
23:16:01:292   [1016/231601.216:WARNING:browser_info.cc(309)] Returning a speculative frame for 30064771081 [7,9]
23:16:01:292   [1016/231601.216:WARNING:browser_info.cc(309)] Returning a speculative frame for 30064771081 [7,9]
23:16:01:292   [1016/231601.221:WARNING:browser_info.cc(309)] Returning a speculative frame for 30064771078 [7,6]
23:16:01:292   [1016/231601.222:WARNING:browser_info.cc(309)] Returning a speculative frame for 30064771078 [7,6]
23:16:01:292   [1016/231601.222:WARNING:browser_info.cc(309)] Returning a speculative frame for 30064771078 [7,6]
23:16:01:292   [1016/231601.223:WARNING:browser_info.cc(309)] Returning a speculative frame for 30064771078 [7,6]
23:16:01:539   CefRequestContextHandlerMap::GetHandler(const content::GlobalRenderFrameHostId &, bool): global_id.child_id = 8
23:16:01:793   CefRequestContextHandlerMap::RemoveHandler(const content::GlobalRenderFrameHostId &): global_id.child_id = 6
23:16:01:793   CefRequestContextHandlerMap::RemoveHandler(const content::GlobalRenderFrameHostId &): global_id.child_id = 6
....
...
...


Problematic requests have global_id.child_id = 8. I can see in the log, this ID was never registered before or after GetHandler(). Also after closing the app the RemoveHandler is never called for global_id.child_id = 8.
It seems like browser process is never notified about this child, but I don't know who is supposed to send the notification.
rado
Expert
 
Posts: 145
Joined: Wed Oct 05, 2011 3:32 am

Re: OnBeforeResourceLoad not called for some XHRs

Postby rado » Wed Oct 25, 2023 11:45 am

I've tried to debug it for long time, but I'm in endless loop, I don't know where is the problem, why the request handler is not installed for new render frame with new id.
I'll have to find some workaround for my problem, if somebody would be interested it can be seen here: https://fbs.com/cabinet/recovery
No fbs.com/api requests are caught by the handler
rado
Expert
 
Posts: 145
Joined: Wed Oct 05, 2011 3:32 am

Re: OnBeforeResourceLoad not called for some XHRs

Postby magreenblatt » Wed Oct 25, 2023 1:10 pm

rado wrote:I've tried to debug it for long time, but I'm in endless loop, I don't know where is the problem, why the request handler is not installed for new render frame with new id.
I'll have to find some workaround for my problem, if somebody would be interested it can be seen here: https://fbs.com/cabinet/recovery
No fbs.com/api requests are caught by the handler

Can you add a bug? Thanks. (Note: I can't promise that we'll get to it soon).
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

PreviousNext

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 185 guests