Bug 1378

Summary: NewtCanvasSWT Overlap on MacOSX with Multiple RCP perspectives
Product: [JogAmp] Newt Reporter: Marcel Au <marcel.au>
Component: macosxAssignee: Sven Gothel <sgothel>
Status: RESOLVED DUPLICATE    
Severity: normal CC: gouessej
Priority: P4    
Version: 2.4.0   
Hardware: All   
OS: macosx   
Type: DEFECT SCM Refs:
Workaround: ---
Bug Depends on: 1358    
Bug Blocks: 674    
Attachments: An opened 3D perspective
Opened non 3D perspective - 3D view overlaps other views
Another 3D perspective
Overlap of 3D view in another selected perspective
3D view reparenting the NEWTCanvasSWT

Description Marcel Au 2019-04-18 16:06:49 CEST
JogAmp version:2.3.2

Platforms working: Windows 10, Linux Ubuntu 18.10 (GTK3), Debian Stretch (GTK3)
Platforms exposing the issue: MacOSX Mojave (tested)

This error occurs in an Eclipse RCP application with several perspectives wheras each perspective integrates several views. In my case two perspectives contains JOGL NEWT canvas (NewtCanvasSWT). When the perspectives are opened and active everything is displayed correctly. However if I switch to another non 3D perspective (in which I can open a 3D view, too) the 3D canvas is still visible and overlaps the other views.
If I open the 3D view in the current perspective the NewtCanvasSWT get's reparented.

Expected behavior as occurring on Windows and Linux with several Eclipse perspectives
1) Open a 3d perspective with a JOGL NEWT SWT view
2) Switch to another perspective with no JOGL NEWT view enabled.
The 3d view is hidden since it is not opened in this perspective


Erroneous behavior as occurring on MacOSX Mojave
1) Open a 3d perspective with a JOGL NEWT SWT view
2) Switch to another perspective with no JOGL NEWT view enabled.
3) ERROR: The JOGL NEWT view from the 3d perspective overlaps the views of the current perspective
4) Enable the 3D view in the current perspective the NEWT canvas will be parented in this view and don't overlap other views in the current perspective.
Comment 1 Marcel Au 2019-04-18 16:13:25 CEST
Created attachment 808 [details]
An opened 3D perspective
Comment 2 Marcel Au 2019-04-18 16:14:44 CEST
Created attachment 809 [details]
Opened non 3D perspective - 3D view overlaps other views
Comment 3 Marcel Au 2019-04-18 16:15:24 CEST
Created attachment 810 [details]
Another 3D perspective
Comment 4 Marcel Au 2019-04-18 16:16:06 CEST
Created attachment 811 [details]
Overlap of 3D view in another selected perspective
Comment 5 Marcel Au 2019-04-18 16:17:04 CEST
Created attachment 812 [details]
3D view reparenting the NEWTCanvasSWT
Comment 6 Marcel Au 2019-04-18 16:22:39 CEST
I think the bug could be reproduced on MacOSX with Eclipse running a JOGL NEWTCanvasSWT view as a plugin and then switching perspectives.

At the moment I can only reproduce it in my application:

https://bio7.org
Comment 7 Julien Gouesse 2019-04-19 10:09:55 CEST
(In reply to Marcel Au from comment #6)
> I think the bug could be reproduced on MacOSX with Eclipse running a JOGL
> NEWTCanvasSWT view as a plugin and then switching perspectives.
> 
> At the moment I can only reproduce it in my application:
> 
> https://bio7.org

We'll really need a SSCCE in order to be sure that the culprit is in JOGL itself.
Comment 8 Marcel Au 2019-04-19 10:40:05 CEST
(In reply to Julien Gouesse from comment #7)
> (In reply to Marcel Au from comment #6)
> > I think the bug could be reproduced on MacOSX with Eclipse running a JOGL
> > NEWTCanvasSWT view as a plugin and then switching perspectives.
> > 
> > At the moment I can only reproduce it in my application:
> > 
> > https://bio7.org
> 
> We'll really need a SSCCE in order to be sure that the culprit is in JOGL
> itself.

I try to create a simple example after my easter vacation. I think a SWT canvas with two tabs (one with NEWTCanvasSWT) should reproduce the behaviour on Mac.
Comment 9 Marcel Au 2019-05-22 09:55:10 CEST
I've made an hopefully reproducible example:

https://github.com/Bio7/Jogl/tree/master/JoglMacBug/src/newt

This example is a SWT Shell with two tabs embedded.

One tab embedds the Newt JOGL canvas. The other tab is empty.

On, e.g., Windows when I switch to the second(empty) tab the Newt canvas
is hidden. The Newt JOGL canvas itself (first tab) is resizeable.

On MacOSX when I switch to the empty tab the Newt canvas still overlays the tab.
Resizing of the Newt tab doesn't work properly (moving the shell is possible, though).

In addition an JOGL icon is set (which is annoying when you have embedded JOGL in an app whith it's own icon because it replaces the app icon in the dock)
Comment 10 Marcel Au 2019-05-23 15:13:52 CEST
This bug seems to similar to this older bug with NewtAWT:

https://jogamp.org/bugzilla/show_bug.cgi?id=1274
Comment 11 Julien Gouesse 2019-05-23 16:00:30 CEST
(In reply to Marcel Au from comment #10)
> This bug seems to similar to this older bug with NewtAWT:
> 
> https://jogamp.org/bugzilla/show_bug.cgi?id=1274

Do you suspect a particular change in some source code common to NewtCanvasAWT and NewtCanvasSWT?
Comment 12 Marcel Au 2019-05-23 16:22:03 CEST
(In reply to Julien Gouesse from comment #11)
> (In reply to Marcel Au from comment #10)
> > This bug seems to similar to this older bug with NewtAWT:
> > 
> > https://jogamp.org/bugzilla/show_bug.cgi?id=1274
> 
> Do you suspect a particular change in some source code common to
> NewtCanvasAWT and NewtCanvasSWT?

Not for me to say. I just recently switched  from SWT_AWT to Newt (which comes with an impressive performance gain). 

I just saw this older thread which might be related. 
I think that somehow the NewtCanvasSWT resize and visible commands are not transfered from the SWT canvas to the embedded Newt window (if my example is correct since I found no swt newt example at all).
Comment 13 Marcel Au 2019-05-23 16:30:49 CEST
I will try to manipulate the NEWT window with an SWT listener at the weekend on my Mac. Maybe I can find out more if it is related to the NewtSWTCanvas or the embedded Newt window itself. Linux and Windows should work though.
Comment 14 Marcel Au 2019-05-27 13:58:20 CEST
(In reply to Julien Gouesse from comment #11)
> (In reply to Marcel Au from comment #10)
> > This bug seems to similar to this older bug with NewtAWT:
> > 
> > https://jogamp.org/bugzilla/show_bug.cgi?id=1274
> 
> Do you suspect a particular change in some source code common to
> NewtCanvasAWT and NewtCanvasSWT?

It seems to me that the newt window implementation is responsible for this behaviour.
The scale in the linked example with JOGL 2.3.2 is also not correct. 


I fixed that in my NewtCanvas implementation here:

https://github.com/Bio7/bio7/blob/master/com.eco.bio7.WorldWind/src/com/eco/bio7/worldwind/swt/NewtCanvasSWT.java#L129

However I'm not able to hide the Newt window if a tab change occur (see example).
Comment 15 Julien Gouesse 2019-05-27 16:44:47 CEST
(In reply to Marcel Au from comment #14)
> (In reply to Julien Gouesse from comment #11)
> > (In reply to Marcel Au from comment #10)
> > > This bug seems to similar to this older bug with NewtAWT:
> > > 
> > > https://jogamp.org/bugzilla/show_bug.cgi?id=1274
> > 
> > Do you suspect a particular change in some source code common to
> > NewtCanvasAWT and NewtCanvasSWT?
> 
> It seems to me that the newt window implementation is responsible for this
> behaviour.
> The scale in the linked example with JOGL 2.3.2 is also not correct. 
> 
> 
> I fixed that in my NewtCanvas implementation here:
> 
> https://github.com/Bio7/bio7/blob/master/com.eco.bio7.WorldWind/src/com/eco/
> bio7/worldwind/swt/NewtCanvasSWT.java#L129
> 
> However I'm not able to hide the Newt window if a tab change occur (see
> example).

Thank you for the feedback. It's better than nothing, I don't feel comfortable with using DPIUtil as it's an internal class, it's not in the public official API but your workaround gives a clear idea of how to fix a symptom of this bug and where.
Comment 16 Sven Gothel 2019-08-20 20:05:46 CEST
Fix to Bug 1358 might be related as it also intends to fix the scaling issue using DPIUtil.

Marcel + Julien, thank you for your energy here.

Our SWT code is currently our little stepchild, needing a bit more love :)

So what shall we do from here?
Best if we can get Bug 1358 (in git repo already) changes
and your changes (same? + windowing event) merged + tested ?!

Promoted for version 2.4.0, if this can be done this week.
Comment 17 Marcel Au 2019-08-21 13:27:33 CEST
Hello Sven, 

merging would be great. 

And yes SWT needs more love:

"Doubt thou the stars are fire;
Doubt that the sun doth move;
Doubt truth to be a liar;
But never doubt I love."

William Shakespeare, Hamlet 

Shamelessly pasted from:
https://www.goodreads.com/quotes/tag/love?page=3
Comment 18 Sven Gothel 2019-08-22 19:21:19 CEST
(In reply to Marcel Au from comment #17)
> Hello Sven, 
> 
> merging would be great. 
> 
> And yes SWT needs more love:
> 
> "Doubt thou the stars are fire;
> Doubt that the sun doth move;
> Doubt truth to be a liar;
> But never doubt I love."
> 
> William Shakespeare, Hamlet 
> 
> Shamelessly pasted from:
> https://www.goodreads.com/quotes/tag/love?page=3

Very nice lyrics.

So how will we remove all doubts and give it some love?
You or me providing the initial patch/diff file?

Material love :)
Comment 19 Marcel Au 2019-08-23 10:54:46 CEST
Hello Sven,

it would be great if you could give the material love because you now the already made changes/suggestions of the Bug 1358.

However for the future is this the right repo to make a pull request?

https://github.com/sgothel/jogl

In additon I could make a small example for SWT using the faster NEWTCanvasSWT in the Wiki(do I need a login?). I had some problems to find a SWT example and it could be useful for others.
Comment 20 Sven Gothel 2020-01-13 17:48:55 CET
(In reply to Marcel Au from comment #0)
I assume Bug 1421 comment 30 related commit does also fix this issue?

> One more to fix TabFolder etc .. (Hide/Show)
> 
> commit 39af5ca418d0db9669aca5db77fa47e801e2a1d9
>
>    Bug 1421 Related: Handle SWT Events: Activate (focus), Show and Hide.
>    
>    Show and Hide handling resolves TabFolder layout,
>    i.e. hiding the 'hidden' and showing the current tab.

Also re-org all SWT related bugs - making them blocking children of Bug 674.
Goal is to have most of 'em closed for 2.4.0.
Comment 21 Sven Gothel 2020-01-15 12:33:17 CET
Resolved while working on Bug 1421. 

Namely Bug 1421 comment 37 and onwards (NEWT child window issue)

*** This bug has been marked as a duplicate of bug 1421 ***