aspose file tools*
The moose likes Applets and the fly likes Image loading very slow from URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Image loading very slow from URL" Watch "Image loading very slow from URL" New topic
Author

Image loading very slow from URL

Florin Florentin
Ranch Hand

Joined: May 12, 2009
Posts: 43
Hello.

I have an applet in which i want to load 2 images, one from my hard-disk and one from an url adress. The applet is loading both of the images, the problem is that is taking too long to load the images (more than 10 sec). The applet is blank untill the url images is loaded, and this is taking too long. If i click run file from the IDE to see the Applet Viewer it's working fine, both images are are loaded very quick. The problem is only when i want to see the applet in the browser. I added the applet in an HTML file with the applet tag.



My applet is extending the JApplet class.
Thank you, and Happy NEW YEAR !
Adriano Tissier
Greenhorn

Joined: Dec 30, 2009
Posts: 4
Hello there,

I'm having the same issue, in a more general aspect as it spreads out all over the applet logic.
Not only loading from a single URL is VERY slow inside a browser, it freezes when having concurrent access to an URL (even using threads).
The "getImage" method is supposed to be asynchronous, yet when calling it multiple times it unexpectedly freezes.

I can see the parallel between our two issues Florin and although a solution surely exists, it's been very random to find anything related on the web.

Hope somehow could enlighten us both on that.

Thank you all!
Adriano Tissier
Greenhorn

Joined: Dec 30, 2009
Posts: 4
Alright,

Seems like the issue is not 'Image' related but more like 'URL' related.
When loading a single Image from an URL, the applet does not freeze. Sure, it's still extremely slow from what i'd expect, but the applet logic runs without worrying about the image being loaded.
However, when trying to access a second URL the applet does freeze.

Florin, how about loading one image? Is it still slow? Is your applet still blank?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41815
    
  62
It's quite possible that the applet JVM restricts the number of network connections ot a particular host (just like the browser doesn't open unlimited connections to a particular host).

Also note that the getImage call returns immediately, without waiting for the image to be loaded. You may want to use a MediaTracker to get notified when it's done.


Ping & DNS - my free Android networking tools app
Florin Florentin
Ranch Hand

Joined: May 12, 2009
Posts: 43
My applet is slowing when loading URL images, even if i try to load only 1 image.

I tried also to use MediaTracker, but unfortunately the behaviour is the same.

My question is, why when i run the file in the applet viewer it's working fine, but in my browser it's running so slow?
Adriano Tissier
Greenhorn

Joined: Dec 30, 2009
Posts: 4
Ulf,

It looks like you are on the right track.
I've been thinking and it seems that the only difference between running an applet in the applet viewer and in a browser lies in the policy file.
Be it my issue, which I first thought was what Florin experienced, or his, although they are somehow related, it is explained by the applet viewer allowing every security rule, well, as far as I understand it.

Would the solution be signing the applet and authorizing a magic what's-its-name security rule?
Hope not, I don't feel like paying to get a certificate from a CA...
EDIT: I modified my policy file and it works like a charm!
It's not slow anymore and concurrent access does not block the applet either.
This lad has it working without signing the applet, I'm still trying to figure out why.


Nonetheless, it's pretty strange that nobody ever ran into this problem, loading (multiple) image(s) from somewhere is something pretty common in RIAs.

Oh, and shouldn't be accessing resources (like images) from a different domain not authorized by default applet policies?
The more you dig in this, the more you get confused, eh. ; )
EDIT: nevermind the above comment, found later that crossdomain.xml do the trick since Java update 10

Thanks so far!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Image loading very slow from URL