readAndDispatch Causing Hang With Browser [message #480322] |
Sat, 15 August 2009 01:32 |
Jesse Messages: 3 Registered: July 2009 |
Junior Member |
|
|
I have a SWT Browser embedded in an AWT Canvas. The Browser is normally
used for displaying ads. Some of these ads are Flash. Most of the time
readAndDispatch takes under 50-150 ms. For certain Flash ads it
skyrockets to 15000 ms. During this time the GUI hangs. This is causing
major issues with the application.
Is there anything that can be done? Can the readAndDispatch call be
cancel?
Thanks,
Jesse
Here is the test case code I am using:
import java.awt.Canvas;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Test1 {
public static void main(String args[]) {
JFrame f = new JFrame();
Canvas canvas = new Canvas();
f.setSize(800,500);
f.add( canvas );
f.setVisible(true);
Display display = new Display();
Shell shell = SWT_AWT.new_Shell(display, canvas);
shell.setSize(800,600);
Browser browser = new Browser(shell, SWT.NONE);
browser.setLayoutData( new GridData(GridData.FILL_BOTH));
browser.setSize(800,600);
browser.setUrl("MYURL");
browser.setVisible( true );
shell.open();
while(!shell.isDisposed()) {
before = System.currentTimeMillis();
boolean more = display.readAndDispatch();
after = System.currentTimeMillis();
if ( after - before != 0 )
System.out.println( after - before );
if(!more)
display.sleep();
}
display.dispose();
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02184 seconds