Skip navigation.
 
mlRe: knowing when WebView is done
FROM : Rush Manbert
DATE : Fri Jun 06 19:39:04 2008

Darn, I thought I had a code example in my library, but I must have 
decided that I really didn't need to know when the load completed, 
because I don't have anything implemented.

I did take a look at the "Loading Resources" chapter of the "Web Kit 
Objective-C Programming Guide" to try and remember what I thought I 
would do. I don't know if this is helpful, but here it is.

When I receive webView:didStartProvisionalLoadForFrame:, set my 
outstanding resource count to zero.

Every time I receive 
webView:resource:didReceiveResponse:fromDataSource:, increment my 
outstanding resource count.

Every time I receive webView:resource:didFinishLoadingFromDataSource: 
or  webView:resource:didFailLoadingWithError:fromDataSource:, 
decrement my outstanding resource count.

Theoretically, when my outstanding resource count goes to zero during 
the load, the page load is complete. But it always seemed to me that 
there would be race conditions in this, and there might be a time 
during a page load when the count would temporarily go to zero before 
a new resource starts loading. I also don't know what the sequence 
would be like for a page that had separate frames. Would I see 
webView:didStartProvisionalLoadForFrame: for each frame in the page? 
Maybe that's why I punted on it.

Sorry that I can't be of more help.

- Rush

On Jun 5, 2008, at 7:03 PM, Timothy Ritchey wrote:

> Here is a typical trace for a failing load for me ("main" is the 
> name I've given to the frame):
>
> 2008-06-05 21:56:40.539 Vigil[43952:10b] didCommitLoadForFrame: main
> 2008-06-05 21:56:40.546 Vigil[43952:10b] didReceiveTitle: main
> 2008-06-05 21:56:40.598 Vigil[43952:10b] didReceiveIcon: main
> 2008-06-05 21:56:41.622 Vigil[43952:10b] didCommitLoadForFrame: <!--
> framePath /main/<!--frame0-->-->
> 2008-06-05 21:56:41.623 Vigil[43952:10b] didReceiveTitle: <!--
> framePath /main/<!--frame0-->-->
> 2008-06-05 21:56:41.720 Vigil[43952:10b] didFinishLoadForFrame: <!--
> framePath /main/<!--frame0-->-->
> 2008-06-05 21:56:41.721 Vigil[43952:10b] didFinishLoadForFrame: main
> 2008-06-05 21:56:41.851 Vigil[43952:10b] 
> WebViewProgressFinishedNotification
> 2008-06-05 21:56:41.855 Vigil[43952:10b] didReceiveTitle: main
>
>
> even if I track frame commit/finish load as suggested in the thread, 
> if I try to get rid of the webview, the world falls down around me 
> when it can't push out that last delegate call of didReceiveTitle. I 
> tried even counting title/icon, etc. and that didn't even help (you 
> can see there are two calls to the title delegate, both for the main 
> frame. There just doesn't appear to be a deterministic way to figure 
> out when WebView is actually done, and safe to release.
>
>
> On Jun 5, 2008, at 8:24 PM, Rush Manbert wrote:
>

>>
>> On Jun 5, 2008, at 3:23 PM, Mark Bateman wrote:
>>

>>> Tim,
>>>
>>> I use the webviewdidfinishload method I'm not usre if that is any 
>>> use to you...I'm quite new so I hope I'm not missing something 
>>> obvious in your message.
>>>

>>
>> See this thread:
>>
>> http://lists.apple.com/archives/webkitsdk-dev/2005/Dec/msg00047.html
>>
>> -Rush
>>

Related mailsAuthorDate
mlknowing when WebView is done Timothy Ritchey Jun 5, 19:54
mlRe: knowing when WebView is done Mark Bateman Jun 6, 00:23
mlRe: knowing when WebView is done Rush Manbert Jun 6, 02:24
mlRe: knowing when WebView is done Timothy Ritchey Jun 6, 03:31
mlRe: knowing when WebView is done Timothy Ritchey Jun 6, 04:03
mlRe: knowing when WebView is done Rush Manbert Jun 6, 19:39
mlRe: knowing when WebView is done Adam R. Maxwell Jun 7, 01:06
mlRe: knowing when WebView is done Timothy Ritchey Jun 7, 07:06
mlRe: knowing when WebView is done Adam R. Maxwell Jun 7, 07:32
mlRe: knowing when WebView is done Timothy Ritchey Jun 7, 15:26
mlRe: knowing when WebView is done Adam R. Maxwell Jun 7, 17:02
mlRe: knowing when WebView is done Timothy Ritchey Jun 11, 15:42
mlRe: knowing when WebView is done Timothy Ritchey Jun 16, 01:34