Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 530324 - Add -Dswt.dbus.init to eclipse.ini files
Summary: Add -Dswt.dbus.init to eclipse.ini files
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Releng (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Leo Ufimtsev CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-25 12:11 EST by Leo Ufimtsev CLA
Modified: 2018-02-01 15:35 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Ufimtsev CLA 2018-01-25 12:11:25 EST
For SWT.OpenDocument and SWT.OpenUrl to function properly, the following needs to be added as jvm arg:
-Dswt.dbus.init

I'll be updating relevant *.product files simmilar to when -XstartOnFirstThread was added to eclipse.ini files.

See:

528414 – (swtWaylandLauncher) [Gtk3][Wayland] Launcher segfault under Wayland when openFile is used
https://bugs.eclipse.org/bugs/show_bug.cgi?id=528414

525305 – [API]Provide SWT.OpenUrl event
https://bugs.eclipse.org/bugs/show_bug.cgi?id=525305
Comment 1 Eclipse Genie CLA 2018-01-25 12:16:36 EST
New Gerrit change created: https://git.eclipse.org/r/116059
Comment 3 Leo Ufimtsev CLA 2018-01-25 12:25:29 EST
We should also consider adding this flag to some projects downstream.
Comment 4 Mickael Istria CLA 2018-01-25 12:39:45 EST
Why not having this value assumed it's true by default so it's enabled without any necessary change in all .product files of the world?
Comment 5 Leo Ufimtsev CLA 2018-01-25 15:26:22 EST
(In reply to Mickael Istria from comment #4)
> Why not having this value assumed it's true by default so it's enabled
> without any necessary change in all .product files of the world?

Hmmm. I thought about it for a while.

@Alex, what about if we init GDBus only when a user adds a SWT.OpenUrl/SWT.OpenDocument listener?
Like upon registering the listener, gdbus is fired up.

I could wip together a proof of concept in <30 mins.
Comment 7 Leo Ufimtsev CLA 2018-01-25 16:56:50 EST
(In reply to Mickael Istria from comment #4)
> Why not having this value assumed it's true by default so it's enabled
> without any necessary change in all .product files of the world?

To avoid conflicting unique (aka well-known) session bus "org.eclipse.swt".
Ex, we wouldn't want an app like "Vuze" stealing org.eclipse.swt name, otherwise if both eclipse and vuze are running, vuze might steal the session bus name.

But this could potentially be avoided if we only init gdbus if/when we add OpenDocument/OpenUrl listener.
Comment 8 Alexander Kurtakov CLA 2018-01-26 00:48:31 EST
(In reply to Leo Ufimtsev from comment #5)
> (In reply to Mickael Istria from comment #4)
> > Why not having this value assumed it's true by default so it's enabled
> > without any necessary change in all .product files of the world?
> 
> Hmmm. I thought about it for a while.
> 
> @Alex, what about if we init GDBus only when a user adds a
> SWT.OpenUrl/SWT.OpenDocument listener?
> Like upon registering the listener, gdbus is fired up.
> 
> I could wip together a proof of concept in <30 mins.

Will that work for the launcher case?
Comment 9 Alexander Kurtakov CLA 2018-01-26 00:55:10 EST
(In reply to Mickael Istria from comment #4)
> Why not having this value assumed it's true by default so it's enabled
> without any necessary change in all .product files of the world?

Mickael, for the record OpenDocument (the way it was implemented prior to M5) relied on X11 atoms which were set by eclipse executable only thus eclipse launched with java -jar launcher.jar was not supporting it. So what Leo proposes is net addition opening the possibility to use the new dbus based method so in theory we don't need this for every product to change (possibly very few people launch eclipse that way) it's a matter of opening the door for people working on the dbus code itself (inner eclipse) or trying to work on other code using the dbus method to do new integration. IMHO if we can get Platform and EPP packages it's good enough for now.
With that said if Leo manages to make it more dynamic without the system property - that would be perfect.
Comment 10 Mickael Istria CLA 2018-01-26 05:36:47 EST
(In reply to Leo Ufimtsev from comment #7)
> To avoid conflicting unique (aka well-known) session bus "org.eclipse.swt".
> Ex, we wouldn't want an app like "Vuze" stealing org.eclipse.swt name,
> otherwise if both eclipse and vuze are running, vuze might steal the session
> bus name.

Could we have unique session bus id for each app. So it would be "org.eclipse.swt.<launcherName>" or something like that that allows to distinguish apps?
Comment 11 Leo Ufimtsev CLA 2018-01-26 10:56:28 EST
(In reply to Alexander Kurtakov from comment #8)
> (In reply to Leo Ufimtsev from comment #5)
> > (In reply to Mickael Istria from comment #4)
> > > Why not having this value assumed it's true by default so it's enabled
> > > without any necessary change in all .product files of the world?
> > 
> > Hmmm. I thought about it for a while.
> > 
> > @Alex, what about if we init GDBus only when a user adds a
> > SWT.OpenUrl/SWT.OpenDocument listener?
> > Like upon registering the listener, gdbus is fired up.
> > 
> > I could wip together a proof of concept in <30 mins.
> 
> Will that work for the launcher case?

*In theory* yes.

This could potentially simplify the launcher in that we could remove setting of the gtk platform-specific flag in the eclipseGtk.c code altogether.

I'll experiment and report my findings.
Comment 12 Leo Ufimtsev CLA 2018-01-26 12:04:22 EST
(In reply to Mickael Istria from comment #10)
> (In reply to Leo Ufimtsev from comment #7)
> > To avoid conflicting unique (aka well-known) session bus "org.eclipse.swt".
> > Ex, we wouldn't want an app like "Vuze" stealing org.eclipse.swt name,
> > otherwise if both eclipse and vuze are running, vuze might steal the session
> > bus name.
> 
> Could we have unique session bus id for each app. So it would be
> "org.eclipse.swt.<launcherName>" or something like that that allows to
> distinguish apps?

We do this for webkit extension. Every eclipse has a unique session bus.
But for opening files, clients usually expect a well known 'aka unique' session bus.

It's possible to have a '<launcherName>' extension to the session name of sort, e.g set by a System Property. Would be ~2 extra lines of code in GDBus.java. 
But there should probably be some kind of use case first?
Comment 13 Alexander Kurtakov CLA 2018-01-26 12:07:34 EST
(In reply to Leo Ufimtsev from comment #12)
> (In reply to Mickael Istria from comment #10)
> > (In reply to Leo Ufimtsev from comment #7)
> > > To avoid conflicting unique (aka well-known) session bus "org.eclipse.swt".
> > > Ex, we wouldn't want an app like "Vuze" stealing org.eclipse.swt name,
> > > otherwise if both eclipse and vuze are running, vuze might steal the session
> > > bus name.
> > 
> > Could we have unique session bus id for each app. So it would be
> > "org.eclipse.swt.<launcherName>" or something like that that allows to
> > distinguish apps?
> 
> We do this for webkit extension. Every eclipse has a unique session bus.
> But for opening files, clients usually expect a well known 'aka unique'
> session bus.
> 
> It's possible to have a '<launcherName>' extension to the session name of
> sort, e.g set by a System Property. Would be ~2 extra lines of code in
> GDBus.java. 
> But there should probably be some kind of use case first?

Having the launcherName property will be totally useless as none of the products rebuild the native launcher thus it will always be the same for all.
Comment 14 Mickael Istria CLA 2018-01-26 12:25:14 EST
(In reply to Alexander Kurtakov from comment #13)
> Having the launcherName property will be totally useless as none of the
> products rebuild the native launcher thus it will always be the same for all.

The launcher name shouldn't be included in the launcher code, but computed dynamically at runtime. For Red Hat Developers Studio, it's `devstudio`. This is the launcher name that should be considered to name the bus with.
Comment 15 Leo Ufimtsev CLA 2018-01-26 12:26:58 EST
(In reply to Mickael Istria from comment #14)
> (In reply to Alexander Kurtakov from comment #13)
> > Having the launcherName property will be totally useless as none of the
> > products rebuild the native launcher thus it will always be the same for all.
> 
> The launcher name shouldn't be included in the launcher code, but computed
> dynamically at runtime. For Red Hat Developers Studio, it's `devstudio`.
> This is the launcher name that should be considered to name the bus with.

One option is to have the name be "org.eclipse.swt" as default, and optionally append a post-fix via System Property if there is need for it.
Comment 16 Leo Ufimtsev CLA 2018-01-26 14:37:55 EST
Proof of concept works:
530397 – [Gtk] Make gdbus initialization dynamic
https://bugs.eclipse.org/bugs/show_bug.cgi?id=530397

There's no need for the swt.gdbus.init property and by extension no need for adding the vmarg to *.product files.
Comment 17 Leo Ufimtsev CLA 2018-01-26 14:48:38 EST
Ok, so making gdbus dynamic appears to be the better approach.

To be continued in:
530397 – [Gtk] Make gdbus initialization dynamic
https://bugs.eclipse.org/bugs/show_bug.cgi?id=530397

The gdbus session naming is a slightly different issue that can be handled independently. If there is a need to have a separate session bus, feel free to open a bug with use case and we can implement the feature. (~3 lines of code probably).

Thanks for your suggestion!