Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set cookies in Browser component with libwebkit2gtk 4.1 in Ubuntu 24.04 due to libsoup 3 incompatibility #1710

Open
miscose opened this issue Jan 7, 2025 · 0 comments

Comments

@miscose
Copy link

miscose commented Jan 7, 2025

Describe the bug
When running SWT on Ubuntu 24.04 LTS with libwebkit2gtk 4.1 (default), Browser.setCookie always fails (returns false). It works with libwebkit2gtk 4.0 on earlier Ubuntu versions. This seems to be due to libwebkit2gtk 4.1 upgrading to libsoup 3 and SWT only supporting libsoup 2.

To Reproduce

  1. Install "Eclipse IDE for RCP and RAP Developers" 2024-12 on Ubuntu 24.04 LTS
  2. Run this SWT snippet in a Java project: (with swt.jar from swt-4.34-gtk-linux-x86_64.zip on the classpath)
package setcookietest;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class SetCookieTest {

	public static void main(String[] args) throws Exception {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());
		Browser browser = new Browser(shell, SWT.WEBKIT);
		browser.setUrl("http://www.eclipse.org/swt");
		browser.addProgressListener(ProgressListener.completedAdapter(_ -> {
			boolean success = Browser.setCookie("cookie1=value1", "http://www.eclipse.org/swt");
			System.out.println("setCookie: " + success);
			System.exit(success ? 0 : 1);
		}));
		
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

}
  1. Note that you get this output:
SWT WebKit: SoupURI == 0 when setting cookie
setCookie: false
  1. Try the same on Ubuntu 20.04 LTS and get this output:
setCookie: true

Expected behavior
The same behavior on Ubuntu 24.04 LTS as on Ubuntu 20.04 LTS.

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)

Ubuntu 24.04.1 LTS

  1. JRE/JDK version

OpenJDK 23.0.1 (org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_23.0.1.v20241024-1700/jre)

Version since
Support for Ubuntu 24.04 LTS is claimed as "Target Environment" for the Eclipse platform since 2024-09, see https://eclipse.dev/eclipse/development/plans/eclipse_project_plan_4_33.xml#target_environments, so it could count as a bug since Eclipse/SWT 4.33.

Workaround (or) Additional context
Possibly there could be other incompatibilities with libsoup 3 than settings cookies.
The problem would likely be exposed by the test Test_org_eclipse_swt_browser_Browser.test_get_set_Cookies(), but this test seems to have been inadvertently disabled by 50da5ad since webkitGtkVersionInts is no longer initialized.
No known workaround, besides trying to manually downgrade libwebkit2gtk to 4.0.

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

No branches or pull requests

1 participant