Webview error reporting
Closed this issue · 17 comments
Hi,
Would be great if there was a way to know if navigating to an URL has worked.
Unless I am missing something, I don't see any error reporting.
Thanks !
AFAIK none of the native APIs give any kind of return code for their navigate functions. It's all async, so I guess there's no way to know what's happened until later. I guess what's needed is a way of asking what the status of the loaded page is?
Too busy to dig into that right now, but will leave it here as a FR..
Yep that would do the trick.
Juce webview own version has some callback to do that
pageLoadHadNetworkError, pageFinishedLoading
so being able to set custom std::function for those would be great.
Thanks !
I'm trying to add this myself but I'm having a hard time figuring how you bind stuff with class_addMethod
I do see in the debugger WebPageProxy::didFailProvisionalLoadForFrame: frameID=4, isMainFrame=1, domain=NSURLErrorDomain, code=-1009, isMainFrame=1
I suppose I should bind like that
class_addMethod (delegateClass, sel_registerName ("webView:didFailProvisionalLoadWithError:forFrame:"),
(IMP) (+[](id self, SEL, id, id, id)
{
but no success.
Any hint is welcomed :)
Thanks !
That code looks correct to me. When you say "no success", what's actually going wrong?
I think I miss some inner knowledge of how it should work
as it looks like I need to call setFrameLoadDelegate to the same delegate you are using in Pimpl ctor
but
call<void> (webview, "setFrameLoadDelegate:", delegate);
fail
My objC knowledge and webkit framework seems too limited
Yeah, finding out how any of this stuff works is a nightmare, there's almost no documentation. I've mainly just found random code examples and used trial-and-error for a lot of it. But yes, it does sound like to need to find whatever the method is that attaches this delegate in the right way. I also pushed another change yesterday which does something similar for yet another type of delegate - maybe that could be a clue..
BTW, it looks like that method is from the WebFrameLoadDelegate class, which is deprecated. Might be worth finding out what its replacement is before putting too much effort into getting that working?
you pointed in the right direction
I need to call
call<void> (webview, "setNavigationDelegate:", delegate);
in the ctor
and then add a callback on
webView:didFailProvisionalNavigation:withError:
Will investigate further
Here is a quick diff which at least show the error message like it happens on Windows
diff.txt
Can give you some start to implement something like Juce own version does.
The drawsBackground to false allows to have a custom paint showed while the page is loading
OK, ta, I'll see if I can add something along those lines
I've moved to something like that in my latest test.
diff2.txt
I've checked how to do something similar on Windows but this is not 2 line of code
OK, well I've added the message display to get things started. Can add the callback function at some point when we can do it on more than one platform
yep on Windows at least you have a default error message so this is more annoying on OSX indeed
I think with library code like this it's always a good policy to avoid anything fancy! When there's a callback, people can customise it however they like
Just wanted to mention that OSX WebKit reports some error which are not really error
like NSURLErrorCancelled so I did something like that in my fork
otristan@a69edca
Oh, good catch, thanks, I'll add something for that.