native.newWebView's URLRequest event.type 'loaded' not behaving on iOS devices

Hello folks,

The native.newWebView’s URLRequest event listener does not work properly on iOS devices. It works fine in the simulator, but not so well when deployed to an actual iOS device (confirmed using 3GS and iPad 2).

Code to replicate the behavior on a device is as follows and available for download at :

local txt1, txt2, webView local function webListener( event ) txt1.text = "Event URL: " .. event.url txt1:setReferencePoint( display.TopLeftReferencePoint ) txt1.x = 150 txt2.text = "Event TYPE: " .. event.type txt2:setReferencePoint( display.TopLeftReferencePoint ) txt2.x = 150 end txt1 = display.newText("Event URL:", 50, 90, native.systemFont, 30 ) txt2 = display.newText("Event TYPE:", 50, 130, native.systemFont, 30 ) webView = native.newWebView( 50, 280, 680, 680 ) webView:request( "http://www.coronalabs.com/" ) webView:addEventListener( "urlRequest", webListener )

The ’ loaded’ event.type (as described in http://docs.coronalabs.com/api/event/urlRequest/type.html) only gets triggered once! Unfortunately, that particular event.type never gets triggered again; all subsequent page requests don’t report the ’ loaded’ event. For example, if one were to deploy the above code to an iOS device, the ’ loaded’ event.type gets passed to the listener once www.coronalabs.com has successfully loaded into the webview…however, all other pages that are accessed from then on (e.g clicking on the “Corona”, “Community”, “Resources”, “Blog” hyperlinks) ’ loaded’ event.type never gets passed to the event listener. 

The above behavior only occurs on iOS devices. It works fine in the Corona simulator (mac version) and all event.types work as one would expect; every time the webview completes loading a new page, it passes ’ loaded’ to the listener as one would expect.

I was wondering if there is a work around for this or if there is a “fix” for it in the works. Perhaps there is another way to do this? My big picture idea is to use the “link” event.type and “loaded” event.type to help determine when to begin / stop the spinner widget for providing feedback to the enduser that a page is currently loading.

Regards

Hi @tbuttner,

I asked the engineers for details on this. I may need you to file this test project as a bug report… I’ll keep you updated.

Thanks,

Brent Sorrentino

Brent,

I was wondering if the engineers have had a chance to address this?

Regards

Hi @tbuttner,

I asked the engineers for details on this. I may need you to file this test project as a bug report… I’ll keep you updated.

Thanks,

Brent Sorrentino

Brent,

I was wondering if the engineers have had a chance to address this?

Regards

I am experiencing this as well, so would appreciate an update. I’m currently using the latest Daily Build (2013.1203) so it obviously is still an issue. I, too, have no trouble catching the ‘loaded’ event type on iOS simulator but as soon as I throw it onto our iPhone 4 developer phone it fails any subsequent loaded events after the first trigger. Same piece works dandy on Android (physical and simulator)

We just started back on general bug fixes and additions since finishing up the deep testing on the last public build.  If you have not done so, please file a bug report on this if you have a simple block of code that shows the problem (sounds like you do).  

Bug report was filed on 9/5 and assigned Case#26034 and received the following response: 

Hello,  I do see the different between iOS and Simulator/Android. I’ll pass this along to Engineering to see if there is something that can be done. It may be a limitation of Apple’s UIWebView because I believe we are just passing along the events we receive.

 

Hopefully this issue will be addressed soon.

If webView is a native UI component, based on Apple document, 

https://developer.apple.com/library/ios/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instp/UIWebView/loading

there is a loading property that is very helpful to determine if the webView is currently loading something or not…

loading

A Boolean value indicating whether the receiver is done loading content. (read-only)

@property(nonatomic, readonly, getter=isLoading) BOOL loading

 

Hope this property can be added into Corona webView too.

Joe, would you mind going to http://feedback.coronalabs.com and adding that feature request there?  It’s how we track feature requests.

Thanks

Rob

Hey Rob (or other), until this is fixed (or this ‘feature’ is added) you guys should put a ‘Gotcha’ on the docs page explaining this strangeness to anyone out there that may expect the ‘loaded’ event to behave the same across Simulator/Android/iOS.

Hi @sdmg_developer_1,

Thanks for the feedback. I’ll add this “gotcha” to the documentation later today.

Brent

I am experiencing this as well, so would appreciate an update. I’m currently using the latest Daily Build (2013.1203) so it obviously is still an issue. I, too, have no trouble catching the ‘loaded’ event type on iOS simulator but as soon as I throw it onto our iPhone 4 developer phone it fails any subsequent loaded events after the first trigger. Same piece works dandy on Android (physical and simulator)

We just started back on general bug fixes and additions since finishing up the deep testing on the last public build.  If you have not done so, please file a bug report on this if you have a simple block of code that shows the problem (sounds like you do).  

Bug report was filed on 9/5 and assigned Case#26034 and received the following response: 

Hello,  I do see the different between iOS and Simulator/Android. I’ll pass this along to Engineering to see if there is something that can be done. It may be a limitation of Apple’s UIWebView because I believe we are just passing along the events we receive.

 

Hopefully this issue will be addressed soon.

If webView is a native UI component, based on Apple document, 

https://developer.apple.com/library/ios/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instp/UIWebView/loading

there is a loading property that is very helpful to determine if the webView is currently loading something or not…

loading

A Boolean value indicating whether the receiver is done loading content. (read-only)

@property(nonatomic, readonly, getter=isLoading) BOOL loading

 

Hope this property can be added into Corona webView too.

Joe, would you mind going to http://feedback.coronalabs.com and adding that feature request there?  It’s how we track feature requests.

Thanks

Rob

Hey Rob (or other), until this is fixed (or this ‘feature’ is added) you guys should put a ‘Gotcha’ on the docs page explaining this strangeness to anyone out there that may expect the ‘loaded’ event to behave the same across Simulator/Android/iOS.

Hi @sdmg_developer_1,

Thanks for the feedback. I’ll add this “gotcha” to the documentation later today.

Brent

This is still not fixed as of 2013.1260.  It works great on simulator and Android but on iOS device it only ever fires once as previously mentioned.

Please fix, as it’s been two months since the bug report was issued, and I really need this to update my app.

Thanks.