[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Does browser rendering occur in the Display thread?

Thanks for the response. According to that test it's in the UI thread, or at least the paint events are which I would think they have to be. The thing that concerns me is that loading of content in any browser is asynchronous, at least when doing this via javascript, and they make callbacks to allow you to know when a page has been loaded (ready state). So would SWT remove that behavior and force them to be synchronous? Anyway even with that test I'm still having problems.

I think my problem is actually a little more complicated than I initially stated. I'm trying to run javascript on load of the page. This then sets the window.status allowing me to receive the StatusTextEvent. But I'm having problems writing an abbott test that allows me to inspect this as it seems that the event fires after, or sometimes before, the flushing of all events (while (display.readAndDispatch()) so I'm having problems asserting the behavior. I'm going to think about this more. Thanks for the suggestion and if you have any others I'm all ears.

Thanks,
Brad

Daniel Spiewak wrote:
I'm fairly sure it does occure in the event dispatch thread.  It's fairly easy to check.  Try the following snippet:

[code]
public static void main(String[] args) {
    Display display = new Display();

    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());

    Browser b = new Browser(shell);
    b.setUrl("http://www.google.com";);

    GridData data = new GridData();
    data.horizontalAlignment = SWT.FILL;
    data.verticalAlignment = SWT.FILL;
    data.grabHorizontalSpace = true;
    data.grabVerticalSpace = true;
    b.setLayoutData(data);

    Button b = new Button(shell, SWT.PUSH);
    b.setText("Push Me!");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            while (true);
        }
    });

    shell.open();

    while (!shell.isDisposed())
        if (!display.readAndDispatch()) display.sleep();
}
[/code]

Sorry if anything in there is wrong, I just hacked that out from memory. Anyway, push the button and then drag another window over the Shell. If the Browser repaints even when the Button doesn't, then it's a safe bet that the rendering is done in a separate thread. If the Browser doesn't repaint, then the rendering is really done in the event dispatch thread.