Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349837 - Incompatibility between WebKit and XULRunner's sqlite
Summary: Incompatibility between WebKit and XULRunner's sqlite
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: 3.7.1   Edit
Assignee: Grant Gayed CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 357761 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-06-20 11:20 EDT by Snjezana Peco CLA
Modified: 2014-01-01 07:03 EST (History)
19 users (show)

See Also:
Silenio_Quarti: review+


Attachments
WebKit/XULRunner patch (1.35 KB, patch)
2011-06-20 11:22 EDT, Snjezana Peco CLA
no flags Details | Diff
plug-in to try (2.35 MB, application/x-zip-compressed)
2011-06-20 15:06 EDT, Grant Gayed CLA
no flags Details
patch used to create comment #4 attachment (1.36 KB, patch)
2011-06-20 16:26 EDT, Grant Gayed CLA
no flags Details | Diff
patch to allow specification of a browser type for SWT.NONE-style Browsers (1.98 KB, patch)
2011-06-24 12:27 EDT, Grant Gayed CLA
no flags Details | Diff
patch that gives plug-ins the chance to set the "org.eclipse.swt.browser.DefaultType" property (2.08 KB, patch)
2011-07-18 12:40 EDT, Grant Gayed CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Snjezana Peco CLA 2011-06-20 11:20:11 EDT
Build Identifier: I20110613-1736

Eclipse 3.7 uses WebKit as the Browser's underlying renderer. That's why XULRunner crashes on a lot of Linux distributions. 
The solution is to add a variable (org.eclipse.swt.browser.UseWebKitGTK, for instance; this variable exists in Eclipse 3.6.2). If the variable would be set to false, Eclipse wouldn't try to use WebKit (at least when using SWT.NONE). It would also be necessary to load the org.eclipse.swt.browser.WebKitInitializer or some similar class that could set this variable before showing up the Welcome page. The user should be able to decide whether to use WebKit or not. Attached is a patch.

For more details see https://issues.jboss.org/browse/JBIDE-9144

Reproducible: Always
Comment 1 Snjezana Peco CLA 2011-06-20 11:22:10 EDT
Created attachment 198261 [details]
WebKit/XULRunner patch
Comment 2 Max Rydahl Andersen CLA 2011-06-20 12:41:00 EDT
Request for making this a hotbug.

I know this is very late in the process but this regression hard to track down and took us a lot of time to find the root cause of a sudden raise in user errors with our Visual Editor.

Affiliation: Red Hat

Target to get fixed: Optimal 3.7.0.GA, but I know that is not very likely but then at least provide a hotfix for it to be able to distribute as a patch update.

Justification: XulRunner 1.9 is used in JBoss Tools a top 6 most downloaded plugin and JBoss Developer Studio and as far as I know MyEclipse and possibly Atpana uses/bundles it too. Until recently there had not been any problems, but since Eclipse started enabling webkit by default and now leaves no option for disabling it then it becomes impossible to run XulRunner 1.9 with Eclipse on (newer) Linux distros because of incompatibility between the sqllite libraries used by common available xulrunner libs and webkit. 

We wish we could just move to webkit but webkit does not provide the same custom API's needed for tight integration as XulRunner does thus it is not a viable option at this time.

A viable option is if SWT would reinstate the flag that made it possible to disable loading of webkit to allow plugins that uses xulrunner to continue to work.

Thank you
Comment 3 Max Rydahl Andersen CLA 2011-06-20 12:43:41 EDT
Please note that on Windows and OSX this problem is not present, its "only" for Linux distributions.
Comment 4 Grant Gayed CLA 2011-06-20 15:06:23 EDT
Created attachment 198282 [details]
plug-in to try

Can you try substituting the attached plug-in for the one in your Eclipse 3.7?  It doesn't look for the property, but I suspect it will fix your case (need you to verify).
Comment 5 Snjezana Peco CLA 2011-06-20 15:45:51 EDT
(In reply to comment #4)
> Created attachment 198282 [details]
> plug-in to try
> 
> Can you try substituting the attached plug-in for the one in your Eclipse 3.7? 
> It doesn't look for the property, but I suspect it will fix your case (need you
> to verify).

I have tested the attached plugin using Eclipse 3.7RC4. The crash still happens.

Could you describe what you have changed in the plugin or attach a patch?
I have tried to load the xulrunner libraries (swt-xulrunner and swt-xpcominit) in the BrowserFactory.createWebBrowser method before (and after) calling the WebKit.isInstalled() method. 
That helps for Eclipse 3.7RC4, but doesn't help in Eclipse 3.7 I20110613-1736. 
The issue also happens on a Linux 32-bit (Ubuntu 11.04 with XULRunner 1.9.2.16, for instance).

In my opinion, WebKit and XULRunner can't work simultaneously on different Linux distributions. The best solution would be to allow the user to decide what renderer to use.
Comment 6 Grant Gayed CLA 2011-06-20 16:15:52 EDT
The attached plug-in does what you describe, it changes BrowserFactory.createWebBrowser() to attempt to load XULRunner's libraries as the _first_ thing it does on its initial invocation.  As you noted in the JBoss bug, BrowserFactory.createWebBrowser() was already doing something like this.  However its initial reference to WebKit.isInstalled() was circumventing this fix since it was causing WebKitGTK's libraries to be loaded as a side-effect.

> That helps for Eclipse 3.7RC4, but doesn't help in Eclipse 3.7 I20110613-1736

This is surprising because almost nothing in eclipse changed between these two builds, including swt (did not change).  I can only think of two reasons you'd see a difference here:

- Your I20110613-1736 is somehow set up wrong, and you're not actually running with the hack fix that you said fixed 3.7RC4 for you.  Can you verify that your change that loads the XULRunner libaries up-front is definitely running?
- I think p2 changed between these two builds.  With your hack fix in place, can you verify that your XULRunnerInitializer is still being invoked when the first Browser instance is created by Eclipse, as must be happening for you with your 3.7RC4 case?
Comment 7 Grant Gayed CLA 2011-06-20 16:26:47 EDT
Created attachment 198288 [details]
patch used to create comment #4 attachment

patch used to create comment #4 attachment
Comment 8 Snjezana Peco CLA 2011-06-20 16:59:14 EDT
(In reply to comment #7)
> Created attachment 198288 [details]
> patch used to create comment #4 attachment
> 
> patch used to create comment #4 attachment

I have tested your patch. Eclipse still crashes. XULRunnerInitializer is called. I have debugged and checked that.

After that, I have added the following:

BrowserFactory.java
WebBrowser createWebBrowser (int style) {
if (!mozillaLibsLoaded) {
	mozillaLibsLoaded = true;
	Mozilla.LoadLibraries2 ();
}
boolean webkitInstalled = WebKit.isInstalled ();
...

Mozilla.java
...
static void LoadLibraries2() {
	LoadLibraries();
	try {
		Library.loadLibrary ("swt-xulrunner"); //$NON-NLS-1$
	} catch (UnsatisfiedLinkError e) {
		SWT.error (SWT.ERROR_NO_HANDLES, e);
	}
	try {
		Library.loadLibrary ("swt-xpcominit"); //$NON-NLS-1$
	} catch (UnsatisfiedLinkError e) {
		SWT.error (SWT.ERROR_NO_HANDLES, e);
	}	
}
...

I was debuging VPE tests and am sure swt-xulrunner and swt-xpcominit are loaded before loading WebKit.  XULRunner is initialized and the VPE editor opened, but Eclipse 3.7RC4 crashes.
Comment 9 Snjezana Peco CLA 2011-06-20 17:37:50 EDT
(In reply to comment #6)
> 
> > That helps for Eclipse 3.7RC4, but doesn't help in Eclipse 3.7 I20110613-1736
> 
> This is surprising because almost nothing in eclipse changed between these two
> builds, including swt (did not change).  I can only think of two reasons you'd
> see a difference here

Loading XULRunner libraries before WebKit libraries doesn't work either on Eclipse 3.7RC4 or on Eclipse 3.7 I20110613-1736.
I probably removed the system's sqlite when testing this case using Eclipse 3.7RC4 what caused the WebKit libraries not to be loaded and XULRunner to work correctly.
Comment 10 Martin Oberhuber CLA 2011-06-21 08:45:12 EDT
If I get it right, this problem happens only for products which ship their own
copy of Xulrunner, correct? 

At Wind River we're also shipping Xulrunner (1.9.0.10 if that matters) so we'd
be affected too on Ubuntu 10.04 32-bit at least.

So Eclipse 3.7 changed behavior with respect to the default Browser libs being
loaded. Looks like there should be a way for a Product to specify what sort of
Browser should be created for SWT.NONE requests. Such a Preference may also be
interesting on Windows (eg when Xulrunner is shipped with a product and thus
preferrable over IE).
Comment 11 Snjezana Peco CLA 2011-06-21 09:05:33 EDT
(In reply to comment #10)
> If I get it right, this problem happens only for products which ship their own
> copy of Xulrunner, correct? 
> 
The crash can also happen when using the system's XULRunner.
XULRunner uses its own sqlite because its sqlite engine isn't always compatible with the system's sqlite. If XULRunner's sqlite isn't compatible with the system's sqlite that is used by WebKit, you will get the crash.
Comment 12 Grant Gayed CLA 2011-06-21 10:48:42 EDT
Ok, a property will be introduced for 3.7.1 and 3.8.  It will be usable on all platforms, and will allow a browser type to be specified for use by all Browser instances ("all" == at least those created with style SWT.NONE, others TBD).  Patch will follow.
Comment 13 Grant Gayed CLA 2011-06-24 12:27:18 EDT
Created attachment 198550 [details]
patch to allow specification of a browser type for SWT.NONE-style Browsers
Comment 14 Snjezana Peco CLA 2011-06-25 18:36:50 EDT
(In reply to comment #13)
> Created attachment 198550 [details]
> patch to allow specification of a browser type for SWT.NONE-style Browsers

The patch works fine when adding -Dorg.eclipse.swt.browser.DefaultType=mozilla manually.
We, however, have to add that property programmatically. 

Could you add the following (or similar) code:

try {
	Class clazz = Class.forName ("org.eclipse.swt.browser.DefaultBrowserInitializer"); //$NON-NLS-1$
} catch (ClassNotFoundException e) {
	/* no fragment is providing this class, which is the typical case */
}

before line 129
String value = System.getProperty (PROPERTY_DEFAULTTYPE);
in the Browser.java class

as you made the initialization of XULRunner (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=201774#c41)?
Comment 15 Grant Gayed CLA 2011-07-14 11:45:31 EDT
(In reply to comment #14)
Sorry for the late reply.  This can be added, will do it when I return next week.
Comment 16 Grant Gayed CLA 2011-07-18 12:40:30 EDT
Created attachment 199848 [details]
patch that gives plug-ins the chance to set the "org.eclipse.swt.browser.DefaultType" property
Comment 17 Grant Gayed CLA 2011-08-08 12:48:35 EDT
Both parts of the change released to the 3.7.1 and 3.8 streams > 20110808.
Comment 18 Benjamin Pasero CLA 2011-08-17 12:08:03 EDT
I am getting user reports about this SQLite error too, however I am ensuring that Browser get created with SWT.MOZILLA style. Does this fix for 3.7.1 also fix the SQLite issue (XULRunner in our case being shipped together with the product and not the OS one being used) or does it only introduce a flag to use Mozilla for any Browsers created with SWT.NONE?
Comment 19 Grant Gayed CLA 2011-08-17 13:02:56 EDT
The only way to ensure that this error does not happen is to set the org.eclipse.swt.browser.DefaultType property.  If all of your Browsers are created with style SWT.MOZILLA but a SWT.NONE-style Browser from somewhere else (eg.- the Welcome page) is encountered first then the sqlite library that's incompatible with your shipped XULRunner will be loaded, and can cause problems for your XULRunner when it's needed later.
Comment 20 Benjamin Pasero CLA 2011-08-17 14:07:08 EDT
Ok thanks.
Comment 21 Grant Gayed CLA 2011-09-26 10:06:29 EDT
*** Bug 357761 has been marked as a duplicate of this bug. ***