localStorage not persisting across sessions on OSX

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.

localStorage not persisting across sessions on OSX

Postby Liosan » Fri Aug 21, 2015 5:25 am

Hi everyone,

We are using CEF release 3.2357.1281 on our OSX build. We are encountering a problem with localStorage in JS - specifically, it doesn't persist across app restarts. We specify cache_path. The problem is not present in our Windows build. Specifically, we observe the following scenario:
- delete everything in the folder which is used for cache path
- launch app
- notice that something is persisted in local storage (judging by sqlite contents, looks like the first write from JS makes it to the hard drive)
- triger more local storage writing (for example use devtools and execute localStorage.setItem("fooo", "bar")
- notice change is not visible in sqlite db of local storage
- close app
- notice change is still not visible in slqite db of local storage
- restart app
- notice changes are not visible in Javascript

Any way we could debug this? Is this a known issue or should I file a bug? Maybe there could be something wrong in the code of our app? Is there a workaround?

Liosan
Liosan
Techie
 
Posts: 14
Joined: Tue Apr 22, 2014 3:49 am

Re: localStorage not persisting across sessions on OSX

Postby Liosan » Fri Aug 21, 2015 8:38 am

I tested that the sample app cef_binary_3.2357.1290.gce8bb0b_macosx64_client works correctly (when setting cache-path and remote-debugging-port via commandline). So, it means it's a bug in our code. Any hints what could be causing this? Inappropriate shutdown, perhaps?

Liosan
Liosan
Techie
 
Posts: 14
Joined: Tue Apr 22, 2014 3:49 am

Re: localStorage not persisting across sessions on OSX

Postby magreenblatt » Fri Aug 21, 2015 11:21 am

Liosan wrote:Inappropriate shutdown, perhaps?

How does your shutdown differ from cefclient?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: localStorage not persisting across sessions on OSX

Postby Liosan » Mon Aug 24, 2015 5:08 am

We are using ARC, so we don't explicitly destroy our NSWindow. Our tryToTerminate method invokes closeAllBrowsers(), but then we call CefQuitMessageLoop (which indicectly closes and destroys our main window). So onBeforeClose gets called after CefQuitMessageLoop gets called. Could this cause the issue?

Liosan
Liosan
Techie
 
Posts: 14
Joined: Tue Apr 22, 2014 3:49 am

Re: localStorage not persisting across sessions on OSX

Postby magreenblatt » Mon Aug 24, 2015 9:21 am

Liosan wrote:We are using ARC, so we don't explicitly destroy our NSWindow. Our tryToTerminate method invokes closeAllBrowsers(), but then we call CefQuitMessageLoop (which indicectly closes and destroys our main window). So onBeforeClose gets called after CefQuitMessageLoop gets called. Could this cause the issue?

Yes.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: localStorage not persisting across sessions on OSX

Postby Liosan » Mon Aug 24, 2015 9:33 am

OK, then at least I know I'm on the right track. Any possible solutions you could suggest? Is it possible to force browser destruction to happen even though the containing window is not deallocated?

Alternatively, is it possible to flush the localStorage manually?

Liosan
Liosan
Techie
 
Posts: 14
Joined: Tue Apr 22, 2014 3:49 am

Re: localStorage not persisting across sessions on OSX

Postby magreenblatt » Mon Aug 24, 2015 9:58 am

Liosan wrote:OK, then at least I know I'm on the right track. Any possible solutions you could suggest? Is it possible to force browser destruction to happen even though the containing window is not deallocated?

Yes, you can call CloseBrowser and wait for OnBeforeClose to be called for all browsers before calling CefQuitMessageLoop.

Liosan wrote:Alternatively, is it possible to flush the localStorage manually?

No. You will also have other problems if you don't shut down correctly.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: localStorage not persisting across sessions on OSX

Postby Liosan » Mon Aug 24, 2015 10:08 am

magreenblatt wrote:
Liosan wrote:OK, then at least I know I'm on the right track. Any possible solutions you could suggest? Is it possible to force browser destruction to happen even though the containing window is not deallocated?

Yes, you can call CloseBrowser and wait for OnBeforeClose to be called for all browsers before calling CefQuitMessageLoop.


I tried doing that and it resulted in waiting infinitely. Probably because the window is not "destroyed" - as in, we call [window close], but that just minimizes the window. It is still openable. I am currently reseaching destroying the window during app shutdown (or at least the NSView which contains the CEF view).

Liosan
Liosan
Techie
 
Posts: 14
Joined: Tue Apr 22, 2014 3:49 am

Re: localStorage not persisting across sessions on OSX

Postby Liosan » Tue Aug 25, 2015 3:00 am

Liosan wrote:I am currently reseaching destroying the window during app shutdown (or at least the NSView which contains the CEF view).

Removing all children of the main window's contentView helped:

Code: Select all
for (NSView *view in [[[self window] contentView] subviews])
      [view removeFromSuperview];


Even under Automatic Reference Counting this caused the CefView to deallocate, completing the shutdown sequence. So, problem solved :) Thanks for answering our questions.

Liosan
Liosan
Techie
 
Posts: 14
Joined: Tue Apr 22, 2014 3:49 am

Re: localStorage not persisting across sessions on OSX

Postby Liosan » Thu Jul 21, 2016 1:50 am

The problem is back - after upgrade to CEF 2623 local storage is not persisted on both Windows and OSX. Our C++ code didn't change during the upgrade, and the shutdown procedure is as suggested above - and it worked before the upgrade. It works with cefclient. Any ideas?

Liosan
Liosan
Techie
 
Posts: 14
Joined: Tue Apr 22, 2014 3:49 am

Next

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 114 guests