Switching from Awesomium?

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.

Switching from Awesomium?

Postby skln » Tue May 27, 2014 9:44 pm

I was wondering if there was anyone who also switched from awesomium. Just wondering how different the API are and how much work it would be to switch from it. Found out it is running some ancient version of chromium which means less features and problems with websites...
skln
Newbie
 
Posts: 6
Joined: Tue May 27, 2014 9:36 pm

Re: Switching from Awesomium?

Postby fasecero » Wed May 28, 2014 8:46 pm

Hi, English is not my native language, so... well you know...

Due to the problems with websites that you mention I've been forced to replace that great library with CeF3. the API it is somewhat similar.

The most difficult part was the beginning: Implementing CefApp & CefClient to get the 4 basic functions: Init(), Finish(), CreateView() and DestroyView(). A lot of try and error. After this, the rest was easy.

In the process I discovered many similarities but some differences that made ​​me make some important changes:

- In Awesomium I used a class for each Tab or window derived from View that implemented the desired interfaces (dialog, download, ...) . In CeF3 I have one CefApp, and one single CefClient class that implements the interfaces and handles all the opened windows.

- Creating a "view" in Awesomium is synchronous, in Cef3 is asynchronous by using CefSettings.multi_threaded_message_loop = true (windows) practically mandatory for performance reasons.

- Awesomium can run javascript synchronously, in CeF3 you should work asynchronously with the result.
fasecero
Mentor
 
Posts: 60
Joined: Mon May 12, 2014 2:53 pm

Re: Switching from Awesomium?

Postby skln » Thu May 29, 2014 12:00 am

Thanks for the info, i decided to just try implementing it and see what happens :P.
skln
Newbie
 
Posts: 6
Joined: Tue May 27, 2014 9:36 pm

Re: Switching from Awesomium?

Postby morphx » Tue Jun 12, 2018 2:51 pm

Hi skin,

I have a huge project developed using Awesomium and I'm also considering moving to CEF.
I'd really like to know about your experience in doing so.
morphx
Newbie
 
Posts: 3
Joined: Tue Jun 12, 2018 2:47 pm

Re: Switching from Awesomium?

Postby morphx » Thu Jun 14, 2018 9:58 am

Well, I did it.
In case this helps, here are the most important changes I had to make:

1) Any function that executes javascript code through the EvaluateScriptAsync extension function needs to be awaited, otherwise the function call will simply freeze and never return anything back.

2) Calling async functions that use EvaluateScriptAsync to execute javascript code from the FrameLoadEnd is a no no. In order to maintain my original code structure I had to store the function that I wanted to call (using a delegate) and then call the appropriate function from the LoadingStateChanged event handler instead, which is called shortly after FrameLoadEnd.

3) Finally, my original code based on Awesomium 1.7.5.1 instantiated WebSessions through the CreateWebSession static method and set the WebPreferences PdfJS property to False. This caused the internal chromium instance to trigger a download request for any PDF file that was loaded. This allowed me to have full control over the download process through the WebCore.DownloadBegin and WebCore.Download event handlers. Very handy and very easy to implement and maintain.

Unfortunately, there appears to be no way to do this in CefSharp. I tried creating a DownloadHandler and that didn't work. I even tried deleting the pdf_js.pak to no avail. Every time you load a PDF file, the file is simply displayed and it never triggers a download request.

Fortunately, I was able to find a piece code that uses an IRequestHandler and IResponseFilter to manually capture the PDF stream and saves it to a file: https://stackoverflow.com/questions/372 ... p/37418798

I really hope this saves some time to anyone going through the process of moving from Awesomium.
morphx
Newbie
 
Posts: 3
Joined: Tue Jun 12, 2018 2:47 pm

Re: Switching from Awesomium?

Postby magreenblatt » Thu Jun 14, 2018 11:20 am

You can disable the PDF viewer by using the --disable-pdf-extension command-line flag. Loading PDF files should then trigger download instead.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Switching from Awesomium?

Postby morphx » Thu Jun 14, 2018 12:13 pm

Thanks for the information. I will give it a try...
morphx
Newbie
 
Posts: 3
Joined: Tue Jun 12, 2018 2:47 pm


Return to Support Forum

Who is online

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