Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328945

Summary: [SWT_AWT] Application freeze
Product: [Eclipse Project] Platform Reporter: Christopher Deckers <chrriis>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: critical    
Priority: P3 CC: skovatch
Version: 3.7   
Target Milestone: 3.7 M4   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Sample output
none
Console output
none
work in progress
none
Final fix none

Description Christopher Deckers CLA 2010-10-28 12:56:52 EDT
Build Identifier: SWT I20101025-1800

I have an application relying on SWT_AWT, with a particular test case that freezes. It is 100% reproducible.

This occurs with SWT I20101025-1800 and N20101021-2000, tested on 2 different Macs. Using a Safari or XULRunner runtime and 32 bit or 64 bit lib does not make any difference.
This is a regression: SWT 3.7M1 does not have the issue. Windows and Linux do not have the issue.

Let me know if I can be of any help.

Reproducible: Always

Steps to Reproduce:
This time, I was not able to create a small test case narrowing down the issue (sorry), but it is relatively easy to set the environment up. So:
1. Get the NativeSwing distribution from here: https://sourceforge.net/projects/djproject/files/DJ%20Native%20Swing/0.9.9%20preview/
2. Add DJNativeSwing.jar, DJNativeSwing-SWT.jar, DJNativeSwing-SWTDemo.jar, lib/jna/jna.jar and lib/jna/jna_WindowUtils.jar to your classpath, as well as your SWT lib (sources of DJNativeSwing* are part of the distribution if needed).

Once it is set up:
1. Run "chrriis.dj.nativeswing.swtimpl.demo.DemoFrame" (you may need -XstartOnFirstThread)
2. In the tree, click on "JWebBrowser > Simple Example".
3. In the tree, click on "Introduction > Codewise".
-> freeze, nothing responds after that.
Comment 1 Scott Kovatch CLA 2010-10-28 13:34:00 EDT
When the freeze happens, do this. First, find the process ID that's hung. Then do the following:

% sample <pid> 2 20
% kill -QUIT <pid>

Based on the description, the output for 'kill -QUIT' will go to the system console. If launched from Eclipse, it will be in the Eclipse console output pane. Attach the results to this bug; in the meantime I'll look into setting all of this up.
Comment 2 Christopher Deckers CLA 2010-10-28 13:45:58 EDT
Created attachment 181968 [details]
Sample output
Comment 3 Christopher Deckers CLA 2010-10-28 13:46:21 EDT
Created attachment 181969 [details]
Console output
Comment 4 Scott Kovatch CLA 2010-10-28 18:06:50 EDT
Got it: In the embedded case we change the class of the host NSWindow so we can get events. But when the embedded shell is disposed we aren't restoring the class to the one we changed it from. That causes the NSWindow to continue to make callbacks into the SWT, but because there is no longer an SWT object associated with the shell nothing actually happens and we just return 0.
Comment 5 Scott Kovatch CLA 2010-10-28 18:10:20 EDT
Created attachment 182002 [details]
work in progress

This is a short-term fix. If there is more than one embedded shell in a JFrame this won't work. If one of the embedded Shells is closed the class will be reset and no more SWT events will be dispatched.
Comment 6 Christopher Deckers CLA 2010-10-29 02:01:25 EDT
Scott, thanks a lot for looking into this.

> This is a short-term fix. If there is more than one embedded shell in a JFrame
> this won't work. If one of the embedded Shells is closed the class will be
> reset and no more SWT events will be dispatched.

I know some users who are in this case: the web browser is a mean to show Flash animations, and they have several of these. So I hope you have an idea how to complete the fix.

Keep up the good work!
Comment 7 Christopher Deckers CLA 2010-10-29 02:29:30 EDT
> If there is more than one embedded shell in a JFrame this won't work.

In the demo application showing the issue, there are a few examples showing multiple components:
- Additional Features > Constrain Visibility
- Additional Features > Constrain Visibility
- Additional Features > Component Life Cycle (after having clicked on the 2 buttons).

Moreover, all examples would have the issue after clicking the "Source" tab (it creates a web browser).
Comment 8 Scott Kovatch CLA 2010-10-29 13:26:02 EDT
(In reply to comment #7)

> In the demo application showing the issue, there are a few examples showing
> multiple components:
> - Additional Features > Constrain Visibility

Thanks for the pointers! That made it easy to fix. Patch coming shortly; today is M3 day, so this will have to wait a day or two before I can check it in.
Comment 9 Scott Kovatch CLA 2010-10-29 13:26:23 EDT
Created attachment 182065 [details]
Final fix
Comment 10 Scott Kovatch CLA 2010-11-01 11:51:29 EDT
Fixed > 20101101.