Home » Eclipse Projects » Standard Widget Toolkit (SWT) » browser page loading
browser page loading [message #522216] |
Sun, 21 March 2010 11:40 |
Filip 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
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 #522455 is a reply to message #522216] |
Mon, 22 March 2010 17:05 |
Markward Schubert 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 #524349 is a reply to message #524290] |
Wed, 31 March 2010 10:30 |
Grant Gayed 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 #524643 is a reply to message #524421] |
Thu, 01 April 2010 16:18 |
Grant Gayed 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 |
Grant Gayed 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 #527927 is a reply to message #527790] |
Fri, 16 April 2010 23:09 |
Filip 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
|
|
|
Goto Forum:
Current Time: Wed Sep 25 05:08:17 GMT 2024
Powered by FUDForum. Page generated in 0.05508 seconds
|