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.

Problem restoring from local storage

padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Problem restoring from local storage

Post by padamjain »

Hi,

I am using CEF (cef_binary_74.1.19 ) for FMX application. I have below settings in my .dpr file :
GlobalCEFApp.cache := LocalAppDataPath + 'cache';
GlobalCEFApp.cookies := LocalAppDataPath + 'cookie';
GlobalCEFApp.UserDataPath :=LocalAppDataPath + 'userData';
GlobalCEFApp.FrameworkDirPath := 'cef';
GlobalCEFApp.ResourcesDirPath := 'cef';
GlobalCEFApp.LocalesDirPath := 'cef\locales';

The issue is that when i keep cache path to the directory where the exe is, everything works fine.
BUT, when i keep local app data to store cache, localstorage is not working. I need to keep caceh path to local app data because my user doesnt have admin rights to c drive where my application is installed.

Any advises or if I am doing something wrong here?

/Padam
User avatar
salvadordf
Posts: 4034
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problem restoring from local storage

Post by salvadordf »

Hi,

CEF 74 is really old and I don't remember which issues affected that version but I would do this :
  • Check that the LocalAppDataPath has the right value and that it ends with a "\" before concatenating it to another string.
  • Check that the user has write privileges in the directory used for GlobalCEFApp.UserDataPath
  • Check that the application follows the "destruction steps" described in the demo you used as a template for that application. The browser cannot guaratee that the cache, cookies and user data are written correctly if the application closes incorrectly.
  • Consider updating to the latest CEF4Delphi version.
padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Re: Problem restoring from local storage

Post by padamjain »

Thanks for suggesstions.
I think the problem is that when I install the application in C:\programfiles folder then it is not working.
My application is signed by code signing certificate. When i run this signed application from d drive on my pc, everything is working fine.

I dont know if signing is causing some trouble in accessing the folder.

Another strange thing is that even in this case, when i laucnh application i can see Cache, userData folders are created properly. but when i re launched application i can not see if the local storage is used to load settings.

/Padam
padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Re: Problem restoring from local storage

Post by padamjain »

Actually now i have updated to CEF 86.0.23. But still i can not read data from local storage.
i actaully dont know even it is saved or not?
User avatar
salvadordf
Posts: 4034
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problem restoring from local storage

Post by salvadordf »

Try adding a DevTools window to your application. They can be really helpful debugging these issues.

The JSExtension demo has a context menu option to show them here :
https://github.com/salvadordf/CEF4Delph ... n.pas#L400
padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Re: Problem restoring from local storage

Post by padamjain »

That helped and i found the problem in my application.

But, i also found that when i use two instances of my application on same machine. one of them is not able read local storage.
User avatar
salvadordf
Posts: 4034
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problem restoring from local storage

Post by salvadordf »

That's normal.

Two applications can't use the same "cache" directory at the same time. This is a Chromium limitation and all we can do is create several browsers in the same application.
padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Re: Problem restoring from local storage

Post by padamjain »

How would Creating several browsers in same application help in this case.
User avatar
salvadordf
Posts: 4034
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problem restoring from local storage

Post by salvadordf »

When an application creates several browsers CEF will handle the accesses to the cache directory made by all those browsers.
This is necessary to avoid corruption in the data bases and locked files.
padamjain
Posts: 23
Joined: Thu Jan 17, 2019 12:36 pm

Re: Problem restoring from local storage

Post by padamjain »

Ok. Thanks for the resonse.
I just wonder if there could be a way to share local storage between two instances. As that is something we need in our application to use embedded browser.
Post Reply