[webkit-dev] Determine whether all resources have been successfully loaded

Darin Adler darin at apple.com
Fri Aug 3 12:54:23 PDT 2007


On Aug 3, 2007, at 1:50 AM, Plessl Christian wrote:

> 1) didFinishLoadingFromDataSource is also called for the _missing_  
> resource. I would have expected that didFailLoadingWithError is called

I don't think this is a bug.

When confronted with a bad URL, I presume the web server passes back  
an error page. From the point of view of the WebKit API, loading that  
error page is a successful load; many clients want to handle error  
pages just as they would normal content. You can detect that it's an  
error from your point of view by looking at the NSURLResponse object.  
If it's a NSHTTPURLResponse then you can get at statusCode.

> 2) didFinishLoadForFrame myFrame is called, before all resources of  
> frame f2 have been loaded

This might be a bug.

I believe the design is that each frame is independent and parent  
frames don't necessarily wait for subframes. But I could be wrong. It  
might be a bug.

> 3) didFinishLoadForFrame is called although the load was not  
> successfull although. This contradicts Apple's documentation that  
> says: "This method is invoked when a location request for frame has  
> successfully; that is, when all the resources are done  
> loading." (Although the first part of this sentence is unclear and  
> incomplete)

That documentation seems pretty unclear, and quite possibly wrong. You  
can report bugs in the Apple documentation at <http://bugreport.apple.com 
 >.

> What is the recommended way to find out, whether all resources have  
> been loaded successfully?

Besides didFinishLoadForFrame, WebKit doesn't offer another built-in  
way to detect that all resources have been loaded.

"When have all the resources been loaded successfully?" is not a  
specific-enough question. At any point a timer can fire and JavaScript  
can add, say, a new <img> element to a page, creating a new unloaded  
resource. So there's always a potential for additional loading in the  
future. In the general case, there's no single "this page is entirely  
done" point in time. And there is also considerable ambiguity about  
what constitutes failure.

The concept of "completely done loading" that's used for Safari's  
status bar is the progress computation that's done by WebView. It  
sends out a WebViewProgressFinishedNotification when "the load has  
finished"; I think this is the same timing as didFinishLoadForFrame in  
the frame load delegate.

     -- Darin




More information about the webkit-dev mailing list