In my dealings with the JWebBrowser I've noticed that the AWT-EventThread will hang from time to time when displaying certain web content. After some investigation I've seen that it mostly is due to synchronous XmlHttpRequest. I've put together a simple html that will completely hang the SimpleWebBrowserExample when loaded:
<!DOCTYPE html><html><headlang="en"><metacharset="UTF-8"><title></title><script>/** * Synchronous call to non routable address will lock up the browser thread. */functionsleep(){varrequest=newXMLHttpRequest();request.open('GET','http://10.255.255.1/',false);request.send(null);if(request.status===200){console.log(request.responseText);}}</script></head><bodyonload="sleep()">
This page will block indefinitely due to synchronous, unresolvable call on "onload".
</body></html>
This is of course an extreme example but even short blocks on the main thread become quite noticeable when they spill over to the EDT.
When running in SimpleWebBrowser the EDT will hang on: chrriis.dj.nativeswing.swtimpl.components.core.NativeWebBrowser#getResourceLocation
In the application where I use JWebBrowser it rather hangs on:
java.awt.Component#hasFocus at
chrriis.dj.nativeswing.NativeSwing.NIAWTEventListener#adjustNativeComponents at
chrriis.dj.nativeswing.NativeSwing.NIAWTEventListener#eventDispatched
My current solution is to make sure that no webpages that are displayed uses synchronous calls on the main thread, but it would be great if the browser didn't hang the EDT if someone happen to make a problematic web page.
Last edit: itdanne 2015-02-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As far as I know, all I am doing is to delegate to the SWT Browser. If SWT blocks its UI thread, then it will also block the AWT UI thread, and unfortunately I don't think I can do anything about it...
-Christopher
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First of all, thanks for an awesome product!
In my dealings with the JWebBrowser I've noticed that the AWT-EventThread will hang from time to time when displaying certain web content. After some investigation I've seen that it mostly is due to synchronous XmlHttpRequest. I've put together a simple html that will completely hang the SimpleWebBrowserExample when loaded:
This is of course an extreme example but even short blocks on the main thread become quite noticeable when they spill over to the EDT.
When running in SimpleWebBrowser the EDT will hang on: chrriis.dj.nativeswing.swtimpl.components.core.NativeWebBrowser#getResourceLocation
In the application where I use JWebBrowser it rather hangs on:
java.awt.Component#hasFocus at
chrriis.dj.nativeswing.NativeSwing.NIAWTEventListener#adjustNativeComponents at
chrriis.dj.nativeswing.NativeSwing.NIAWTEventListener#eventDispatched
My current solution is to make sure that no webpages that are displayed uses synchronous calls on the main thread, but it would be great if the browser didn't hang the EDT if someone happen to make a problematic web page.
Last edit: itdanne 2015-02-26
Hi,
As far as I know, all I am doing is to delegate to the SWT Browser. If SWT blocks its UI thread, then it will also block the AWT UI thread, and unfortunately I don't think I can do anything about it...
-Christopher