Bug 822 - NewtCanvasSWT: no more rendering after detaching editor from the main EclipseRCP app window
Summary: NewtCanvasSWT: no more rendering after detaching editor from the main Eclipse...
Status: UNCONFIRMED
Alias: None
Product: Newt
Classification: JogAmp
Component: core (show other bugs)
Version: 1
Hardware: All all
: --- critical
Assignee: Petros Koutsolampros
URL:
Depends on:
Blocks: 969
  Show dependency treegraph
 
Reported: 2013-08-29 18:04 CEST by crougier
Modified: 2015-06-05 13:43 CEST (History)
4 users (show)

See Also:
Type: ---
SCM Refs:
Workaround: ---


Attachments
Test case that reproduces the bug (5.27 KB, text/plain)
2015-01-29 22:29 CET, mdehoog
Details

Note You need to log in before you can comment on or make changes to this 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.