Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » browser page loading
browser page loading [message #522216] Sun, 21 March 2010 11:40 Go to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Hello,
in my application I use swt.browser (SWT.MOZILLA) for analyzing web pages. During debugging my application I always load the same page (www.czc.cz). Since certain time (about 10-15 repetition) loading the same page finish (ProgressListener.completed() is invoked) but the page is not fully loaded anymore. Some pictures (one of them is animated gif), ad banners ans some background style are missing.

Could it be server side "feature", cos I have too many requests? I dont think so. I tried load the same page in Firefox with empty cache and it's fine. I tried restart netbeans from where I run my application. I tried restart my computer. Nothing helps.

I guess it will be javascript problem. When I set browser.setJavascriptEnabled(false), all images are loaded fine(event the missing gif). But I want to render the page with javascript enabled.

How does the setUrl exactly work? When is ProgressListener.completed() invoked? After the whole page is loaded and all javascript stuff is finished? Iam not experienced in Javascript a lot Wink

Any ideas where's the problem?

Can I enable any browser debug logging to get more info?

One more question. Sometimes the browser.setUrl "freezes" - no ProgressListener.completed() is invoked. Is it possible to set timeout till when the page has to be loaded.

I use swt-3.6M5-win32-x86,xulrunner-sdk-1.9.1.3-win32, XP SP2.

Thanks a lot for any ideas.

[Updated on: Mon, 29 March 2010 16:19]

Report message to a moderator

Re: browser page loading [message #522421 is a reply to message #522216] Mon, 22 March 2010 15:27 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
> I guess it will be javascript problem. When I set
browser.setJavascriptEnabled(false), all images are loaded fine(event the
missing gif). But I want to render the page with javascript enabled.

This sounds like a good clue. What javascript does the page contain?

> How does the setUrl exactly work? When is ProgressListener.completed()
invoked? After the whole page is loaded and all javascript stuff is
finished? Iam not experienced in Javascript a lot ;)

setUrl() just invokes native API to initiate a request to load a url.
ProgressListener.completed() is sent when a callback is received from the
native renderer some time later indicating that the page load has completed.
Does your page load involve a re-direct to another page? Is the page that
shows this problem publicly accessible?

> Can I enable any browser debug logging to get more info?

No, the only debug info it can print is the location of the native renderer
being used, which would not be helpful here.

> One more question. Sometimes the browser.setUrl "freezes" - no
ProgressListener.completed() is invoked. Is it possible to set timeout till
when the page has to be loaded.

You could do something like:

final Runnable runnable = new Runnable() {
public void run() {
/* timed out */
browser.stop();
}
};
browser.setUrl("http://eclipse.org");
display.timerExec(5000, runnable); /* run after 5s has passed */
browser.addProgressListener(new ProgressAdapter() {
public void completed(ProgressEvent event) {
/* page finished loading on time so cancel the time-out timer */
display.timerExec(-1, runnable);
}
});

HTH,
Grant
Re: browser page loading [message #522455 is a reply to message #522216] Mon, 22 March 2010 17:05 Go to previous messageGo to next message
Markward Schubert is currently offline Markward SchubertFriend
Messages: 15
Registered: July 2009
Junior Member
Hi!

It seems like we are experiencing the same problem with a Mozilla based Browser.

All of a sudden, after days of correctly rendering the webcontent, today the component started having problems with our "dashboard-page", although the content has not changed at all.

Images were missing and javascript was not working properly. I assume, that the external js-files could not be resolved as the whole page seems to have resource resolution errors. The page contains some flash-based videoplayers, which are shown in a nice dynamic popup. In the case of error, the player does not open and instead the flash-movie is shown in fullscreen.

The images have no connection with javascript, they are plain img-tags.

Sometimes even the flash does not open and mozilla pops up a dialog, stating that the resource "path-to-resource" could not be located. In Firefox, opened on my second screen, everything works well.

The issue is not deterministic. During my current development I have to restart the client again and again and sometimes the error occurs, sometimes not.

All missing resources have in common, that they are referenced with relative paths.

In my case the XulRunner was the 1.9.2, bundled with FirefoxPortable.

org.eclipse.swt is version 3.6.0.v3631
org.eclipse.swt.win32.win32.x86 is 3.6.0.v3631

Is there any hack to evade this?

Thanks for any hints!
Re: browser page loading [message #523873 is a reply to message #522421] Mon, 29 March 2010 16:56 Go to previous messageGo to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
>This sounds like a good clue. What javascript does the page contain?
> Is the page that shows this problem publicly accessible?

The page is http://www.czc.cz

Thanks a lot for the snippet with the timer. I will try it.
Re: browser page loading [message #524290 is a reply to message #522421] Wed, 31 March 2010 12:41 Go to previous messageGo to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
I wanted to create a snippet to simulate the problem.

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class RepeatingLoad {

public static void main(String[] args) {

RepeatingLoad test = new RepeatingLoad();
test.test();
}

public void test(){
int limit = 5;
for(int i = 0; i < limit ; ++i) {
try {
TestBrowser tb = new TestBrowser();
tb.start();
tb.join();
System.out.println(i);
} catch (InterruptedException ex) {
System.out.println(ex.getMessage());
}
}
}

public class TestBrowser extends Thread {

@Override
public void run() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.MOZILLA);
shell.open();
browser.setUrl("http://www.czc.cz");
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
}

But when I close the first browser window and new one is going to be created, I get an Exception:
Exception in thread "Thread-1" org.eclipse.swt.SWTError: XPCOM error -2147418113

Does anybody know what's wrong? I guess it's Mozilla problem, cos when I use
Browser browser = new Browser(shell, SWT.NONE);
no exception occures.

Why loading a page with Browser(shell, SWT.NONE); takes about 5 times longer than with Browser(shell, SWT.MOZILLA);

Thanks for any reply.
Re: browser page loading [message #524349 is a reply to message #524290] Wed, 31 March 2010 10:30 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
The XPCOM error is happening because the native browser is unloaded when
your Display is disposed, and Mozilla does not support being re-loaded a
second time in a process. I've changed your snippet to keep one Display
active throughout, and to not use the background thread since all Browser
API interactions need to happen on the main thread anyways. The snippet is
below, and I believe it preserves the intent of your initial snippet.

I don't see the problem that you describe, though I do notice that the
page's content is different for each reload. So maybe they were
occasionally serving up a page with some invalid javascript that caused
problems in the page, but could be averted if javascript was disabled (?).
I don't know if this is what was happening, it's just a theory. Do you
still see the problem with the snippet pasted below?

public static void main(String[] args) {
Device.DEBUG = true;
int limit = 15;
Display display = new Display();
for (int i = 0; i < limit; ++i) {
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.MOZILLA);
shell.open();
browser.setUrl("http://www.czc.cz");
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
System.out.println(i);
}
display.dispose();
}

Grant


"Filip" <filip.pekarek@gmail.com> wrote in message
news:hovfun$2b6$1@build.eclipse.org...
> I wanted to create a snippet to simulate the problem.
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.browser.Browser;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class RepeatingLoad {
>
> public static void main(String[] args) {
>
> RepeatingLoad test = new RepeatingLoad();
> test.test();
> }
>
> public void test(){
> int limit = 5;
> for(int i = 0; i < limit ; ++i) {
> try {
> TestBrowser tb = new TestBrowser();
> tb.start();
> tb.join();
> System.out.println(i);
> } catch (InterruptedException ex) {
> System.out.println(ex.getMessage());
> }
> }
> }
>
> public class TestBrowser extends Thread {
>
> @Override
> public void run() {
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> Browser browser = new Browser(shell, SWT.MOZILLA);
> shell.open();
> browser.setUrl("http://www.czc.cz");
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> display.dispose();
> }
> }
> }
>
> But when I close the first browser window and new one is going to be
created, I get an Exception:
> Exception in thread "Thread-1" org.eclipse.swt.SWTError: XPCOM
error -2147418113
>
> Does anybody know what's wrong? I guess it's Mozilla problem, cos when I
use
> Browser browser = new Browser(shell, SWT.NONE);
> no exception occures.
>
> Why loading a page with Browser(shell, SWT.NONE); takes about 5 times
longer than with Browser(shell, SWT.MOZILLA);
>
> Thanks for any reply.
Re: browser page loading [message #524421 is a reply to message #524349] Wed, 31 March 2010 20:50 Go to previous messageGo to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
>I don't see the problem that you describe, though I do notice that >the page's content is different for each reload. So maybe they were
>occasionally serving up a page with some invalid javascript that >caused problems in the page, but could be averted if javascript >was disabled (?). I don't know if this is what was happening, it's >just a theory.

When the page was not fully loaded in swt browser, loading the same page in Firefox (clean cache) were fine.

Could it be swt browser cache problem? Does swt has any and how does it work?
When the problem occured I tried restart my IDE and computer and nothing helped. Next day everything were fine. It has already happened to me for few times.

> Do you still see the problem with the snippet pasted below?
Everything work fine for me now.
Is there any javascript console or any logging from swt/xulrunner to find out whats wrong when the problem occure next time?

Filip
Re: browser page loading [message #524643 is a reply to message #524421] Thu, 01 April 2010 16:18 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
SWT's Browser doesn't do anything special related to the cache, it just lets
the native browser handle this, so it should behave equivalently to
stand-alone mozilla-based browsers. Note that a separate user profile is
created and shared amongst mozilla-based Browsers, and caching occurs
per-profile. So a resource that is cached by (for instance) stand-alone
firefox will not be available as a cached resource to Browser instances, and
vice-versa. This should not cause a problem like you describe, it just
means that a resource may be cached multiple times.

SWT does not provide any javascript execution info, and I don't think
XULRunner does either. Firebug could be useful here in theory, but it does
not currently integrate with the Browser because it depends on higher-level
XPCOM interfaces that are not included in xulrunner. The only suggestion I
can think of is to Browser.getText() when the problem occurs, to see what
javascript the page contains, and possibly to also provide you with a
reproducable case.

Grant


"Filip" <filip.pekarek@gmail.com> wrote in message
news:hp0ciq$19g$1@build.eclipse.org...
> >I don't see the problem that you describe, though I do notice that >the
page's content is different for each reload. So maybe they were
> >occasionally serving up a page with some invalid javascript that >caused
problems in the page, but could be averted if javascript >was disabled (?).
I don't know if this is what was happening, it's >just a theory.
>
> When the page was not fully loaded in swt browser, loading the same page
in Firefox (clean cache) were fine.
>
> Could it be swt browser cache problem? Does swt has any and how does it
work?
> When the problem occured I tried restart my IDE and computer and nothing
helped. Next day everything were fine. It has already happened to me for few
times.
>
> > Do you still see the problem with the snippet pasted below?
> Everything work fine for me now.
> Is there any javascript console or any logging from swt/xulrunner to find
out whats wrong when the problem occure next time?
>
> Filip
Re: browser page loading [message #524654 is a reply to message #524643] Thu, 01 April 2010 16:57 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
I just had a thought, one thing you can try is Firebug Lite (
http://getfirebug.com/firebuglite ). Here's a snippet of it working with
XULRunner 1.9.2, maybe it will help in your case as well.

public static void main(String[] args) {

System.setProperty("org.eclipse.swt.browser.XULRunnerPath", "e:\\xulrunner-1.
9.2\\xulrunner");
Device.DEBUG = true;
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final Browser browser = new Browser(shell, SWT.MOZILLA);
browser.setLayout(new FillLayout());
browser.setUrl("http://www.google.com");
browser.addLocationListener(new LocationListener() {
public void changing(LocationEvent event) {
}
public void changed(LocationEvent event) {
browser.execute("var headID =
document.getElementsByTagName(\"head\")[0];\r\n"
+ "var newScript = document.createElement('script');\r\n"
+ "newScript.type = 'text/javascript';\r\n"
+ "newScript.src =
' http://getfirebug.com/releases/lite/1.2/firebug-lite-compres sed.js';\r\n"
+ "headID.appendChild(newScript);");
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

HTH,
Grant


"Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
news:hp2h06$m0r$1@build.eclipse.org...
> SWT's Browser doesn't do anything special related to the cache, it just
lets
> the native browser handle this, so it should behave equivalently to
> stand-alone mozilla-based browsers. Note that a separate user profile is
> created and shared amongst mozilla-based Browsers, and caching occurs
> per-profile. So a resource that is cached by (for instance) stand-alone
> firefox will not be available as a cached resource to Browser instances,
and
> vice-versa. This should not cause a problem like you describe, it just
> means that a resource may be cached multiple times.
>
> SWT does not provide any javascript execution info, and I don't think
> XULRunner does either. Firebug could be useful here in theory, but it
does
> not currently integrate with the Browser because it depends on
higher-level
> XPCOM interfaces that are not included in xulrunner. The only suggestion
I
> can think of is to Browser.getText() when the problem occurs, to see what
> javascript the page contains, and possibly to also provide you with a
> reproducable case.
>
> Grant
>
>
> "Filip" <filip.pekarek@gmail.com> wrote in message
> news:hp0ciq$19g$1@build.eclipse.org...
> > >I don't see the problem that you describe, though I do notice that >the
> page's content is different for each reload. So maybe they were
> > >occasionally serving up a page with some invalid javascript that
>caused
> problems in the page, but could be averted if javascript >was disabled
(?).
> I don't know if this is what was happening, it's >just a theory.
> >
> > When the page was not fully loaded in swt browser, loading the same page
> in Firefox (clean cache) were fine.
> >
> > Could it be swt browser cache problem? Does swt has any and how does it
> work?
> > When the problem occured I tried restart my IDE and computer and nothing
> helped. Next day everything were fine. It has already happened to me for
few
> times.
> >
> > > Do you still see the problem with the snippet pasted below?
> > Everything work fine for me now.
> > Is there any javascript console or any logging from swt/xulrunner to
find
> out whats wrong when the problem occure next time?
> >
> > Filip
>
>
Re: browser page loading [message #524756 is a reply to message #524654] Fri, 02 April 2010 10:33 Go to previous messageGo to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Hey Grant,
thanks a lot. I will try it next time the problem occurres.

Filip
Re: browser page loading [message #524822 is a reply to message #524654] Fri, 02 April 2010 18:41 Go to previous messageGo to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Hello,
the problem accurred again but since I tried load the page in the snipped with firebug-lite everything is fine.

Does the firebug lite works only with xulrunner 1.9.2?
How to use it properly? I tried snipped below and it doesn't work.
The "firebug.version" is shown only when I uncomment the first allert in the snippet.

public static void main(String[] args) {
Device.DEBUG = true;
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final Browser browser = new Browser(shell, SWT.MOZILLA);
browser.setLayout(new FillLayout());
browser.setUrl("http://www.czechcomputer.cz");
browser.addProgressListener(new ProgressListener() {

public void completed(ProgressEvent event) {
browser.execute("var headID = document.getElementsByTagName(\"head\")[0];\r\n"
+ "var newScript = document.createElement('script');\r\n"
+ "newScript.type = 'text/javascript';\r\n"
+ "newScript.src = ' http://getfirebug.com/releases/lite/1.2/firebug-lite-compres sed.js';\r\n"
+ "headID.appendChild(newScript);");
//browser.execute("alert(1111);");
browser.execute("alert(firebug.version);");
browser.execute("firebug.init();");
browser.execute("firebug.inspect(document.body.firstChild); ");
}
public void changed(ProgressEvent event) {
}
});

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}

Thanks.

Filip
Re: browser page loading [message #527785 is a reply to message #522421] Fri, 16 April 2010 13:29 Go to previous messageGo to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Hello, I have a question. Does swt.browser.stop() invoke browser.ProgressListener.completed() ? I think it does. But does it always?

I tried to simulate my code in folowing snippet, but the problem doesnt appear.

In my code I sometimes get the log loading page timeout and the program "freezes". Next link is not beying loaded even there are some left. When I check the thread, it sleeps on display.sleep().

Any ideas wheres the problem? It happens only sometimes. Sad

Thanks a lot.

Here's the snippet.

public class RepeatingLoad {

public static List<String> links = new ArrayList<String>();
public static Display display;
public static Browser browser;
public static String location = "http://www.cechcomputer.cz";
public static int linkIndex = 0;
public static int TIMEOUT = 100;

final static Runnable loadKiller = new Runnable() {

public void run() {
System.out.println(" Loading page " + location + " TIME OUT !");
browser.stop();
}
};

public static void main(String[] args) {

loadLinks();
display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
browser = new Browser(shell, SWT.MOZILLA);
shell.open();
browser.setUrl(location);
browser.addProgressListener(new ProgressAdapter() {

@Override
public void completed(ProgressEvent event) {

if (linkIndex < links.size()) {
display.timerExec(TIMEOUT, loadKiller);
location = links.get(linkIndex++);
browser.setUrl(location);
} else {
display.timerExec(-1, loadKiller);
System.out.println("FINISHED !");
}
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}

public static void loadLinks() {
links.add("www.czechcomputer.cz/info.jsp?name=showroom_praha_4_haje ");
links.add("www.czechcomputer.cz/basket.jsp");
links.add("www.czechcomputer.cz/cat_tree.jsp?ppath=");
links.add("www.czechcomputer.cz/product.jsp?artno=72247");
links.add("www.czechcomputer.cz/product.jsp?artno=69905");
links.add("www.czechcomputer.cz/product.jsp?artno=75855");
links.add("www.czechcomputer.cz/product_news.jsp");
links.add("www.czechcomputer.cz/product_actions.jsp");
links.add("www.czechcomputer.cz/product_top_list.jsp");
links.add("www.czechcomputer.cz/product_sale.jsp");
links.add("www.czechcomputer.cz/product_club_list.jsp");
}
}
Re: browser page loading [message #527790 is a reply to message #527785] Fri, 16 April 2010 13:57 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Invocations of browser.stop() should cause ProgressListener.completed() to
be invoked. I would guess that occasional cases where this does not happen
are timing differences caused by the native browser's asynchronous nature.
If your real app is stopping a page load and then immediately initiating a
new one, one hack you can try is to slightly delay the initiation of the new
page load in order to give the cancelled one an extra cycle to complete.
Wrap it in an asyncExec() like:

display.asyncExec(new Runnable() {
public void run() {
if (browser.isDisposed()) return;
browser.setUrl(theUrl);
}
});

HTH,
Grant


"Filip" <filip.pekarek@gmail.com> wrote in message
news:hq9oon$v5c$1@build.eclipse.org...
> Hello, I have a question. Does swt.browser.stop() invoke
browser.ProgressListener.completed() ? I think it does. But does it always?
>
> I tried to simulate my code in folowing snippet, but the problem doesnt
appear.
>
> In my code I sometimes get the log loading page timeout and the program
"freezes". Next link is not beying loaded even there are some left. When I
check the thread, it sleeps on display.sleep().
>
> Any ideas wheres the problem? It happens only sometimes. :(
>
> Thanks a lot.
>
> Here's the snippet.
>
> public class RepeatingLoad {
>
> public static List<String> links = new ArrayList<String>();
> public static Display display;
> public static Browser browser;
> public static String location = "http://www.cechcomputer.cz";
> public static int linkIndex = 0;
> public static int TIMEOUT = 100;
>
> final static Runnable loadKiller = new Runnable() {
>
> public void run() {
> System.out.println(" Loading page " + location + " TIME OUT
!");
> browser.stop();
> }
> };
>
> public static void main(String[] args) {
>
> loadLinks();
> display = new Display();
> Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> browser = new Browser(shell, SWT.MOZILLA);
> shell.open();
> browser.setUrl(location);
> browser.addProgressListener(new ProgressAdapter() {
>
> @Override
> public void completed(ProgressEvent event) {
>
> if (linkIndex < links.size()) {
> display.timerExec(TIMEOUT, loadKiller);
> location = links.get(linkIndex++);
> browser.setUrl(location);
> } else {
> display.timerExec(-1, loadKiller);
> System.out.println("FINISHED !");
> }
> }
> });
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> display.dispose();
> }
>
> public static void loadLinks() {
>
links.add("www.czechcomputer.cz/info.jsp?name=showroom_praha_4_haje ");
> links.add("www.czechcomputer.cz/basket.jsp");
> links.add("www.czechcomputer.cz/cat_tree.jsp?ppath=");
> links.add("www.czechcomputer.cz/product.jsp?artno=72247");
> links.add("www.czechcomputer.cz/product.jsp?artno=69905");
> links.add("www.czechcomputer.cz/product.jsp?artno=75855");
> links.add("www.czechcomputer.cz/product_news.jsp");
> links.add("www.czechcomputer.cz/product_actions.jsp");
> links.add("www.czechcomputer.cz/product_top_list.jsp");
> links.add("www.czechcomputer.cz/product_sale.jsp");
> links.add("www.czechcomputer.cz/product_club_list.jsp");
> }
> }
>
Re: browser page loading [message #527875 is a reply to message #527790] Fri, 16 April 2010 18:15 Go to previous messageGo to next message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Thanks a lot, I will try it.

Filip
Re: browser page loading [message #527927 is a reply to message #527790] Fri, 16 April 2010 23:09 Go to previous message
Filip is currently offline FilipFriend
Messages: 16
Registered: March 2010
Location: Czech Republic
Junior Member
Hello Grant,
I modified my code and now I have a synchronization trouble.

In browser.ProgressListener.completed() I use following code for loading next page from the list:

display.asyncExec(new Runnable() {
public void run() {
display.timerExec(Configuration.getPageLoadTimeout(), loadKiller);
if (browser.isDisposed()) {
return;
}
locStatus.url = rebuild.getLink();
locStatus.set = true;
browser.setUrl(locStatus.url);
}
});

and this code for analyzing sucessfully loaded page:

display.asyncExec(new RebuildWorker(rebuild,
browser.getUrl(),
document,
browser,
display,
loadKiller,
loadTimeout,
locStatus));

locStatus was tended to be my synchronization class.
rebuild is class that analyzes loadad page.
document is loaded nsIDOMDocument.
loadKiller is Runnable that takes care of loading timeout.

RebuildWorker is Runnable and its run method is:

public void run() {
rebuild.processLink(url, document);
display.timerExec(timeout, loadKiller);
locStatus.url = rebuild.getLink();
locStatus.set = true;
browser.setUrl(locStatus.url);
}

My problem is:
e.g. page http://www.czechcomputer.cz/cat_tree.jsp?ppath= includes javascript, that print some message on the page and after a while redirect to the main page. It causes the browser.progressListener.completed() to be invoked two times.
When the listener is invoked for the first time, I process the page successfully and want to set another page to link before the second listener.completed() of pages javascript is invoked.
And here's my point, next listener.completed() is invoked by javascript and not by my browser.setUrl(). It is logical but I need to get around that.

calling my RebuildWorker via display.syncExec solve my problem, byt I am not sure if its the right solution.

I am sure if its a good idea to create so many new instances of my RebuildWorker neither. What do you think? Will java GC take care of it or should I have one instance of RebuildWorker and reuse it?

Do you have any idea for solution using diplay.async so the browser window wount "freeze" when I analyze the page?

And my another question is what exactly means that any widget is disposed and when it is and is not? In the snipped you posted last time when the browser.isDisposed() I stay freezed, dont I. Browser is disposed when e.g. any other thread use it?

Thanks a lot for your time and answers.

Filip
Previous Topic:How to position the caret from mouse cursor in SWT Text
Next Topic:SWT ImageData -- How to obtain number of channels?
Goto Forum:
  


Current Time: Wed Apr 24 15:59:05 GMT 2024

Powered by FUDForum. Page generated in 0.04074 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top