Page 1 of 2

Problem restoring from local storage

Posted: Fri Nov 06, 2020 12:54 pm
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

Re: Problem restoring from local storage

Posted: Sat Nov 07, 2020 8:47 am
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.

Re: Problem restoring from local storage

Posted: Mon Nov 09, 2020 1:44 pm
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

Re: Problem restoring from local storage

Posted: Wed Nov 18, 2020 9:59 am
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?

Re: Problem restoring from local storage

Posted: Wed Nov 18, 2020 10:47 am
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

Re: Problem restoring from local storage

Posted: Thu Nov 19, 2020 11:02 am
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.

Re: Problem restoring from local storage

Posted: Thu Nov 19, 2020 11:17 am
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.

Re: Problem restoring from local storage

Posted: Thu Nov 19, 2020 11:44 am
by padamjain
How would Creating several browsers in same application help in this case.

Re: Problem restoring from local storage

Posted: Thu Nov 19, 2020 11:51 am
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.

Re: Problem restoring from local storage

Posted: Thu Nov 19, 2020 11:56 am
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.