Skip to content

Persist WebKit cookies so the Linux login survives restarts - #1205

Open
creat3dworld wants to merge 1 commit into
Snapmaker:mainfrom
creat3dworld:fix-984-persistent-cookies
Open

creat3dworld wants to merge 1 commit into
Snapmaker:mainfrom
creat3dworld:fix-984-persistent-cookies

Conversation

@creat3dworld

Copy link
Copy Markdown

Closes #984

Also covers #925 and #226 (same root cause — see below).

Root cause

WebKitGTK uses an in-memory cookie store unless persistent storage is explicitly configured. After a successful login the local-storage entries are committed, but no persistent WebKit cookie database is created for the auth web view, so on the next start the embedded web view reports the user as offline and removes both entries + emits a web logout event. This fork has no webkit_cookie_manager_set_persistent_storage call anywhere (verified by grep — zero matches in src/).

Fix

In src/slic3r/GUI/Widgets/WebView.cpp (the shared web-view factory used by the Home/Device/auth pages): (a) declare the WebKit cookie-manager C functions in the existing Linux extern "C" block (following the file's existing pattern of declaring webkit_web_view_run_javascript without including the full WebKitGTK headers), plus the WebKitCookiePersistentStorage enum (SQLITE = 1); (b) new static helper enable_persistent_cookie_storage(wxWebView*) that gets the native WebKitWebView backend, its WebKitWebContext, and the cookie manager, creates data_dir()/cache/ if needed, and enables SQLite persistent storage at data_dir()/cache/cookies.db (same path upstream uses); (c) call it right after webView->Create(...) in the Linux branch of the web-view factory, so it applies to every web view the app creates (Home, Device, auth, preprint) — not only the auth view.

#925 (login not remembered on Linux Mint) and #226 are the same WebKitGTK in-memory cookie store issue, fixed by this patch. No separate patch needed for them.

Based on the v2.4.1 tag. Upstream main has moved 25 commits ahead of v2.4.1; this branch is based on v2.4.1, and the files it touches were not changed on main since v2.4.1, so it should merge cleanly.

Verification: the patch was verified to apply cleanly to a fresh v2.4.1 copy (dry-run + byte-compare). It was NOT compile-tested — this VM has no build toolchain for OrcaSlicer. Real verification: on Linux, log in, close the app, reopen, confirm a cookies.db exists under the data dir and the session is still valid (no re-login).

@KaputterKerl

Copy link
Copy Markdown

Tested this on Linux and the login now survives restarts.

  • Built an AppImage from current main (2.4.2, 19df6ce) with this patch applied (plus fix(linux): build the 3D canvas for GLX so it draws on NVIDIA #1081 so the canvas renders on NVIDIA).
  • Fedora 44 (Nobara), Wayland session, NVIDIA RTX 2070 SUPER (driver 620.70.06), system webkit2gtk4.1 2.54.1.
  • Signed in once, closed the slicer, started it again: I am signed in right at startup. With the official 2.4.1 AppImage I had to log in on every start.

Not tested: the Flatpak build, and whether the cookie database survives an upgrade of the webkit package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux] Snapmaker account login is lost after every restart because WebKit cookies are not persisted

2 participants