Bug 822

Summary: NewtCanvasSWT: no more rendering after detaching editor from the main EclipseRCP app window
Product: [JogAmp] Newt Reporter: crougier
Component: swtAssignee: Petros Koutsolampros <pjgl>
Status: RESOLVED FIXED    
Severity: critical CC: bryan.osborn, gouessej, michael.dehoog, sgothel
Priority: ---    
Version: 2   
Hardware: All   
OS: all   
Type: DEFECT SCM Refs:
Workaround: ---
Bug Depends on:    
Bug Blocks: 969    
Attachments: Test case that reproduces the bug

Description crougier 2013-08-29 18:04:01 CEST
Eclipse Kepler (4.3)
Windows 7 and RedHat 5.2
JOGL 2.0.2

The NewtCanvasSWT is displayed in an editor of an Eclipse RCP app.
When the editor is detached from the main app window to its own window, the 3D scene is no more rendered.
The OpenGL context is not destroyed.
The NewtCanvasSWT handle a resize event with a height value = 0, hence the window is marked as invisible. Then, other resize events with valid values are handled but the window stay in an invisible state.

Originally reported at:
http://forum.jogamp.org/NativeWindowException-Unable-to-lock-surface-td4029205.html

gouessej said:
"You're right, validateNative fails in this case.
Edit.: There is still the same kind of test in NewtCanvasAWT :( "
Comment 1 Sven Gothel 2014-02-26 20:13:26 CET
How can this bug be reproduced ?
As a unit test (best),  manually (bad), or not at all (worst) ?

If we are not able to reproduce a bug, we may have to close it.
Comment 2 mdehoog 2015-01-13 04:22:40 CET
Can confirm that this is indeed an issue. To reproduce, create an Eclipse RCP application, embed a NewtCanvasSWT in a tab, and then detach that tab from the main RCP window so that a new window is created. The NewtCanvasSWT receives two resize events, one with 0,0,0,0, and then another with the correct size.

To fix this issue in our application (https://github.com/GeoscienceAustralia/earthsci/issues/123), I overrode the setBounds(int,int,int,int) method of NewtCanvasSWT as follows:

@Override
public void setBounds(int x, int y, int width, int height)
{
    //do not allow a size of 0,0, because NEWT window becomes invisible
    super.setBounds(x, y, Math.max(1, width), Math.max(1, height));
}
Comment 3 Julien Gouesse 2015-01-13 09:48:32 CET
(In reply to comment #2)
> Can confirm that this is indeed an issue. To reproduce, create an Eclipse
> RCP application, embed a NewtCanvasSWT in a tab, and then detach that tab
> from the main RCP window so that a new window is created. The NewtCanvasSWT
> receives two resize events, one with 0,0,0,0, and then another with the
> correct size.
> 
> To fix this issue in our application
> (https://github.com/GeoscienceAustralia/earthsci/issues/123), I overrode the
> setBounds(int,int,int,int) method of NewtCanvasSWT as follows:
> 
> @Override
> public void setBounds(int x, int y, int width, int height)
> {
>     //do not allow a size of 0,0, because NEWT window becomes invisible
>     super.setBounds(x, y, Math.max(1, width), Math.max(1, height));
> }

Thank you very much for sharing your findings. It confirms what CĂ©line wrote about the resize event:
http://forum.jogamp.org/NativeWindowException-Unable-to-lock-surface-tp4029205p4029700.html
Comment 4 Sven Gothel 2015-01-29 01:04:50 CET
So how do we proceed with the solution in comment 2 ?

Is there a git pull req, or a patch available ?
Or shall somebody (Me, Petros) add this change ?
Comment 5 Julien Gouesse 2015-01-29 10:44:40 CET
(In reply to comment #4)
> So how do we proceed with the solution in comment 2 ?
> 
> Is there a git pull req, or a patch available ?
> Or shall somebody (Me, Petros) add this change ?

Is there any side effect? As I said, there is probably the same problem in NewtCanvasAWT.
Comment 6 mdehoog 2015-01-29 22:29:46 CET
Created attachment 687 [details]
Test case that reproduces the bug

Overriding setBounds() is just a workaround that worked for us. It would be better to fix the bug itself.

I have attached a simple example that reproduces the bug. Two canvases are created, one with an overridden setSize() and one without. When you click the "Set size to 0,0" button, both canvases disappear with a size of 0,0. When you click "Set size to 50,50", only the workaround canvas reappears.
Comment 7 Sven Gothel 2019-03-30 02:59:16 CET
Fixed via bug 969 I assume. Otherwise we need to reopen it.