Skip to content

Commit 64e3809

Browse files
committed
fix(perry-ui-gtk4): webview.rs against webkit6 0.4 / glib 0.20 (v0.5.864)
Real fixes for the 3 compile errors v0.5.851/863 worked around: 1. `error.code()` on `&gtk4::glib::Error` — glib 0.20 dropped the public `code()` accessor. Use `ToGlibPtr` to reach the raw GError and read the i32 code field directly. 2. `CookieManager::delete_all_cookies` removed in webkit6 0.4. Replaced with `WebsiteDataManager::clear(COOKIES, Duration::ZERO, ...)` which is the supported clear-all-since-epoch API. 3. `webview.settings()` ambiguous between `WidgetExt::settings` and `WebViewExt::settings`. Fully qualify to `WebViewExt::settings`. Re-enables: - The doc-tests ubuntu-24.04 / perry-ui-gtk4 matrix entry (disabled v0.5.851) - The release-packages `-p perry-ui-gtk4` build step (disabled v0.5.863) Linux release tarballs will once again ship libperry_ui_gtk4.a.
1 parent 1f2f44e commit 64e3809

3 files changed

Lines changed: 32 additions & 33 deletions

File tree

.github/workflows/release-packages.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,9 @@ jobs:
280280
done
281281
done
282282
283-
# perry-ui-gtk4 build temporarily disabled (v0.5.863): three real
284-
# compile errors in crates/perry-ui-gtk4/src/widgets/webview.rs against
285-
# the gtk4-rs 0.9 / webkit6 0.4 API on ubuntu-24.04+ runners — `glib::Error::code`
286-
# private, `CookieManager::delete_all_cookies` missing, multiple-applicable
287-
# items in scope. Tests-workflow doc-tests-gtk4 entry is also disabled
288-
# (v0.5.851). Tracked separately; re-enable when webview.rs is fixed.
289-
# Until then the Linux release tarballs ship without libperry_ui_gtk4.a,
290-
# so `perry compile --target linux-gtk4` won't link on those bottles —
291-
# but the perry CLI itself ships fine for all Linux users that don't
292-
# use perry/ui.
293-
# - name: Build UI library (Linux glibc)
294-
# if: runner.os == 'Linux' && !endsWith(matrix.target, '-musl')
295-
# run: cargo build --release --target ${{ matrix.target }} -p perry-ui-gtk4
283+
- name: Build UI library (Linux glibc)
284+
if: runner.os == 'Linux' && !endsWith(matrix.target, '-musl')
285+
run: cargo build --release --target ${{ matrix.target }} -p perry-ui-gtk4
296286

297287
- name: Build UI library (Windows)
298288
if: runner.os == 'Windows'

.github/workflows/test.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -638,21 +638,15 @@ jobs:
638638
cmd_xcompile_advisory: "./scripts/run_doc_tests.sh --verbose --xcompile-only"
639639
# Baseline captured from a clean CI run of 24723671119 (900x970).
640640
gallery_advisory: false
641-
# ubuntu-24.04 doc-tests for perry-ui-gtk4 temporarily disabled:
642-
# crates/perry-ui-gtk4/src/widgets/webview.rs has compile errors
643-
# against the gtk4-rs/glib-rs/webkit6 API surface on noble runners
644-
# (`glib::Error::code` private, `CookieManager::delete_all_cookies`
645-
# missing). Tracked separately; re-enable once webview.rs builds
646-
# cleanly against the apt-installed system gtk4 / libwebkitgtk-6.0
647-
# libraries. macOS and Windows doc-tests still gate the release.
648-
# - os: ubuntu-24.04
649-
# ui_backend: perry-ui-gtk4
650-
# shell: bash
651-
# cmd_exclude_gallery: "xvfb-run -a ./scripts/run_doc_tests.sh --verbose --skip-xcompile --filter-exclude ui/gallery.ts"
652-
# cmd_gallery: "xvfb-run -a ./scripts/run_doc_tests.sh --verbose --skip-xcompile --filter ui/gallery.ts"
653-
# cmd_xcompile_blocking: "./scripts/run_doc_tests.sh --verbose --xcompile-only --xcompile-only-target=web --xcompile-only-target=wasm --xcompile-only-target=ios-simulator"
654-
# cmd_xcompile_advisory: "./scripts/run_doc_tests.sh --verbose --xcompile-only"
655-
# gallery_advisory: false
641+
- os: ubuntu-24.04
642+
ui_backend: perry-ui-gtk4
643+
shell: bash
644+
cmd_exclude_gallery: "xvfb-run -a ./scripts/run_doc_tests.sh --verbose --skip-xcompile --filter-exclude ui/gallery.ts"
645+
cmd_gallery: "xvfb-run -a ./scripts/run_doc_tests.sh --verbose --skip-xcompile --filter ui/gallery.ts"
646+
cmd_xcompile_blocking: "./scripts/run_doc_tests.sh --verbose --xcompile-only --xcompile-only-target=web --xcompile-only-target=wasm --xcompile-only-target=ios-simulator"
647+
cmd_xcompile_advisory: "./scripts/run_doc_tests.sh --verbose --xcompile-only"
648+
# Baseline captured under Xvfb (900x1024).
649+
gallery_advisory: false
656650
# windows-2022 doc-tests for perry-ui-windows temporarily disabled:
657651
# 30+ doc-test snippets COMPILE_FAIL on the Windows runner with
658652
# perry exit 1 (mix of platform-banner gaps and #463-unimplemented

crates/perry-ui-gtk4/src/widgets/webview.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,13 @@ fn install_signal_handlers(handle: i64, webview: &webkit6::WebView) {
220220
if on_error == 0.0 {
221221
return false;
222222
}
223-
let code = error.code() as f64;
223+
// glib::Error doesn't expose `code()` in glib 0.20+; reach into the
224+
// underlying GError struct via ToGlibPtr to read the raw i32 code.
225+
let code = unsafe {
226+
use gtk4::glib::translate::ToGlibPtr;
227+
let ptr: *const gtk4::glib::ffi::GError = error.to_glib_none().0;
228+
(*ptr).code as f64
229+
};
224230
let msg = error.message().to_string();
225231
let msg_nb = nanbox_str(&msg);
226232
let closure_ptr = unsafe { js_nanbox_get_pointer(on_error) } as *const u8;
@@ -309,10 +315,17 @@ pub fn clear_cookies(handle: i64) {
309315
WEBVIEW_STATES.with(|s| {
310316
if let Some(st) = s.borrow().get(&handle) {
311317
if let Some(session) = st.webview.network_session() {
312-
let cookie_mgr = session.cookie_manager();
313-
if let Some(mgr) = cookie_mgr {
318+
// webkit6 0.4 removed CookieManager::delete_all_cookies in
319+
// favor of WebsiteDataManager::clear with a type bitmask.
320+
// COOKIES bitflag + duration 0 = "all cookies since epoch".
321+
if let Some(dm) = session.website_data_manager() {
314322
let cancellable: Option<&gtk4::gio::Cancellable> = None;
315-
mgr.delete_all_cookies(cancellable, |_| {});
323+
dm.clear(
324+
webkit6::WebsiteDataTypes::COOKIES,
325+
std::time::Duration::ZERO,
326+
cancellable,
327+
|_| {},
328+
);
316329
}
317330
}
318331
}
@@ -323,7 +336,9 @@ pub fn set_user_agent(handle: i64, ua_ptr: *const u8) {
323336
let ua = str_from_header(ua_ptr).to_string();
324337
WEBVIEW_STATES.with(|s| {
325338
if let Some(st) = s.borrow().get(&handle) {
326-
if let Some(settings) = st.webview.settings() {
339+
// WidgetExt::settings and WebViewExt::settings collide — fully
340+
// qualify to the WebView one.
341+
if let Some(settings) = webkit6::prelude::WebViewExt::settings(&st.webview) {
327342
settings.set_user_agent(Some(&ua));
328343
}
329344
}

0 commit comments

Comments
 (0)