Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Error with DevTools on MiniBrowser demos

Post Reply
shobits1
Posts: 25
Joined: Wed Mar 04, 2020 9:16 pm

Error with DevTools on MiniBrowser demos

Post by shobits1 »

I was trying to see how I can use the ExecuteDevToolsMethod but kept failing on me, so I decided to open the MiniBrowser demos to see how it's done; but for some reason the demos shows error whenever I call the clear cache method (see the attachement).

please, can you confirm that this problem on my side only or general one.

btw,
I removed/uninstalled old cef4delphi component
removed old dcp and bpl files
updated cef4delphi to current git master repository
downloaded "CEF 87.1.12 / Chromium 87.0.4280.88" binary files

[edit]
I'm using the win32 version
You do not have the required permissions to view the files attached to this post.
User avatar
salvadordf
Posts: 4052
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Error with DevTools on MiniBrowser demos

Post by salvadordf »

Hi,

It seems that the DevTools method is working because the success parameter is True but Chromium is returning an empty JSON in the result parameter. The result only has 2 characters : "{}".

This is the reason why MiniBrowser shows that message. I'll update that demo to ignore the empty result.

Thanks!
User avatar
salvadordf
Posts: 4052
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Error with DevTools on MiniBrowser demos

Post by salvadordf »

I just uploaded the fix for this issue. Please, download CEF4Delphi from GitHub again.
shobits1
Posts: 25
Joined: Wed Mar 04, 2020 9:16 pm

Re: Error with DevTools on MiniBrowser demos

Post by shobits1 »

I think the problem is still there.
debugging:
TMiniBrowserFrm.Clearcache1Click
|-----> TChromiumCore.ClearCache
...|-----> TChromiumCore.ExecuteDevToolsMethod
......|----> Result := Browser.Host.ExecuteDevToolsMethod(message_id, method, params)

the result is 0 which means there was an error as cef documentation says:
///
// Execute a function call over the DevTools protocol. This is a more
// structured version of SendDevToolsMessage. |message_id| is an incremental
// number that uniquely identifies the message (pass 0 to have the next number
// assigned automatically based on previous values). |function| is the
// function name. |params| are the function parameters, which may be NULL. See
// the DevTools protocol documentation (linked above) for details of supported
// functions and the expected |params| dictionary contents. This function will
// return the assigned message ID if called on the UI thread and the message
// was successfully submitted for validation, otherwise 0. See the
// SendDevToolsMessage documentation for additional usage information.
//

maybe I'm doing something wrong!!!
User avatar
salvadordf
Posts: 4052
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Error with DevTools on MiniBrowser demos

Post by salvadordf »

When the documentation mentions the "UI thread" it refers to a CEF thread called "UI" which is not the same as the main application thread.

The TMiniBrowserFrm.Clearcache1Click procedure is executed in the main application thread so it returns 0.

If you need the message ID then you have several options :
  • Call TChromiumCore.ExecuteTaskOnCefThread to trigger the TChromiumCore.OnExecuteTaskOnCefThread event in the right CEF thread.
  • Call CefPostTask with a custom task like TCefFastTask that calls a custom procedure in the right CEF thread.
shobits1
Posts: 25
Joined: Wed Mar 04, 2020 9:16 pm

Re: Error with DevTools on MiniBrowser demos

Post by shobits1 »

ok, it works.

thanks alot :D
Post Reply