CefResourceHandler broken after CEF update

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.

CefResourceHandler broken after CEF update

Postby Stynson » Thu Sep 19, 2019 4:55 am

Hi,

We updated our ~2 years old cef version to a fairly new one ( 76.0.3809.132 )

We used to read local files through custom schemes and the same code now not working with the new CEF version.
HTTP scheme works fine.

I can see that the CefResourceHandler::ReadResponse now deprecated and we should migrate our code to use the Skip + Read API.

My question is that is it possible that the deprecated API already broken and we should use the new one or there might be another issue?

Some extra info:
We try to read a local file via custom scheme we manage to load it then all the data read through the ReadResponse function but the loaded html file never loads in cef
Stynson
Techie
 
Posts: 12
Joined: Thu Jun 27, 2019 10:32 am

Re: CefResourceHandler broken after CEF update

Postby Czarek » Thu Sep 19, 2019 5:45 am

Relevant API changes from the commit log:
API changes:
- Resource-related callbacks have been moved from CefRequestHandler to a new
CefResourceRequestHandler interface which is returned via the
GetResourceRequestHandler method. If the CefRequestHandler declines to handle
a resource it can optionally be handled by the CefRequestContextHandler, if
any, associated with the loading context.
- New methods added to CefResourceHandler that better match NetworkService
execution sequence expectations. The old methods are now deprecated.

Have you tried adding --disable-features=NetworkService switch?
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: CefResourceHandler broken after CEF update

Postby Stynson » Thu Sep 19, 2019 6:43 am

--disable-features=NetworkService did the trick, now it works.

So apparently the methods I used in CefRequestHandler indeed deprecated but I missed the part that for resources you shouldn't use CefRequestHandler at all.

Thanks.
Stynson
Techie
 
Posts: 12
Joined: Thu Jun 27, 2019 10:32 am

Re: CefResourceHandler broken after CEF update

Postby Stynson » Thu Sep 19, 2019 8:58 am

So I disabled the NetworkService hence still using the CefRequestHandler api for loading local files via custom schemes.

With documents loaded this way I am unable to access sessionStorage:
Code: Select all
Failed to read the 'sessionStorage' property from 'Window': Access is denied for this document.


I enabled the CORS for the custom scheme during registration.

Any idea what can cause this issue?
Stynson
Techie
 
Posts: 12
Joined: Thu Jun 27, 2019 10:32 am

Re: CefResourceHandler broken after CEF update

Postby magreenblatt » Thu Sep 19, 2019 9:14 am

When you say "loading local files via custom schemes" what specifically do you mean? Have you compared your code to the sample applications?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefResourceHandler broken after CEF update

Postby Stynson » Thu Sep 19, 2019 10:22 am

I have registered a custom scheme and loading local files from disk with it instead of the file:// portocol (mycustomscheme://)
This way I can use my own filesystem.

Loading files this way I run into the mentioned 'sessionStorage' not accessible issue also CSP issues even tho I specified these flags during the custom scheme creation: CEF_SCHEME_OPTION_CORS_ENABLED | CEF_SCHEME_OPTION_CSP_BYPASSING

The same files work just fine if I run a local webserver and load them that way.

Also this way of loading files worked with the previous CEF versions, not working with the new one.
Stynson
Techie
 
Posts: 12
Joined: Thu Jun 27, 2019 10:32 am

Re: CefResourceHandler broken after CEF update

Postby magreenblatt » Thu Sep 19, 2019 10:27 am

Handling of custom scheme requests is well tested in CEF so there's likely an issue with your client implementation. Can you share your code?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefResourceHandler broken after CEF update

Postby Stynson » Thu Sep 19, 2019 10:44 am

I am pretty sure that the issue is with my implementation :)

I was just wondering if anyone can recall any changes in the API around custom scheme handling that can cause my code to fail with the new CEF version.

Anyway I will try to post some code.

Should we open a new topic for this custom scheme issue?
Stynson
Techie
 
Posts: 12
Joined: Thu Jun 27, 2019 10:32 am

Re: CefResourceHandler broken after CEF update

Postby magreenblatt » Thu Sep 19, 2019 11:01 am

We can keep using the same thread (it provides useful context). Thanks.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: CefResourceHandler broken after CEF update

Postby Stynson » Fri Sep 20, 2019 4:24 am

So I register my custom scheme like this:
Code: Select all
int options = CEF_SCHEME_OPTION_LOCAL | CEF_SCHEME_OPTION_SECURE | CEF_SCHEME_OPTION_CORS_ENABLED | CEF_SCHEME_OPTION_CSP_BYPASSING;
registrar->AddCustomScheme("myscheme", options);


So I explicitely asked for 'CSP ByPassing' but files loaded via this scheme not bypassing the CSP checks.

Is there any other settings I should check regardless CSP ?

I used to register it this way with the old API:
Code: Select all
registrar->AddCustomScheme("myscheme", false, true, false, true, true, true);


For me it worked with the old API but can't bypass CSP with the new one.
Stynson
Techie
 
Posts: 12
Joined: Thu Jun 27, 2019 10:32 am

Next

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 95 guests