magicyuuu / cefpython

Automatically exported from code.google.com/p/cefpython
0 stars 1 forks source link

Cookies not flushed to disk when closing app immediately (wxpython.py) #158

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Noticed this behavior after setting the "cache_path" option in the wxpython.py 
example (it also required setting path in the GetCookieManager callback).

Cookies are flushed to disk only after about 30 seconds. If app is closed 
before that, cookies do not persist.

This is similar to a recent issue I've reported for the PHP Desktop project: 
http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=12357

Original issue reported on code.google.com by czarek.t...@gmail.com on 11 Jan 2015 at 2:15

GoogleCodeExporter commented 9 years ago
Cookies are flushed to disk just fine in the pywin32.py and pyqt.py examples. 
So looks like this is wxPython only issue.

Original comment by czarek.t...@gmail.com on 11 Jan 2015 at 2:52

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Changed OnClose to this:

    if self.browser:
        self.browser.StopLoad()
        self.browser.CloseBrowser(True)
        del self.clientHandler.mainBrowser
        del self.browser
        self.Destroy()

This helped and log messages appear in the right order now - browser is 
destroyed before Shutdown() is called:

    [CEF Python] CefBrowser::CloseBrowser(True)
    [wxpython.py] LifespanHandler::OnBeforeClose
        browserId=1
    [CEF Python] del g_pyFrames[1#1]
    [CEF Python] del g_pyFrames[1#16]
    [CEF Python] del g_pyFrames[1#15]
    [CEF Python] del g_pyFrames[1#14]
    [CEF Python] del g_pyFrames[1#13]
    [CEF Python] del g_pyFrames[1#12]
    [CEF Python] del g_pyFrames[1#11]
    [CEF Python] del g_pyFrames[1#18]
    [CEF Python] del g_pyBrowsers[1]
    [wxpython.py] MyApp.OnExit
    [CEF Python] Shutdown()

However there is still issue with cookies not flushed. Additionaly these sqlite 
cookie errors started appearing in console:

  [CEF Python] del g_pyBrowsers[1]
  [wxpython.py] MyApp.OnExit
  [CEF Python] Shutdown()
  [0111/165253:WARNING:sqlite_persistent_cookie_store.cc(1134)] Failed to post task from content::SQLitePersiste
      ntCookieStore::Backend::Close@browser\net\sqlite_persistent_cookie_store.cc:1021 to background_task_runner_.
  [0111/165253:ERROR_REPORT:sqlite_persistent_cookie_store.cc(121)] Check failed: !db_.get(). Close should have
      already been called.
  [0111/165253:ERROR_REPORT:sqlite_persistent_cookie_store.cc(122)] Check failed: num_pending_ == 0 
      && pending_.empty().

Original comment by czarek.t...@gmail.com on 11 Jan 2015 at 4:02

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 211e1dae20b0.

Original comment by czarek.t...@gmail.com on 11 Jan 2015 at 4:32

GoogleCodeExporter commented 9 years ago
There was still an alive CEF browser reference in the JavascriptExternal 
object. The deletion of pyBrowsers and pyFrames occurs after the call to 
Shutdown(), but it doesn't matter, browser shuts down cleanly and cookies are 
written to disk OK when closing app immediately.

Original comment by czarek.t...@gmail.com on 11 Jan 2015 at 4:32

GoogleCodeExporter commented 9 years ago
Still TODO: update wxpython.py examples on Linux and Mac.

Original comment by czarek.t...@gmail.com on 11 Jan 2015 at 4:37

GoogleCodeExporter commented 9 years ago
Mac scripts were updated. Linux still to do.

Original comment by czarek.t...@gmail.com on 12 Jan 2015 at 10:19