newWebView crash - short sample code

Can someone please help me figure out what I am doing wrong? This code crashes on the device when I run it more than once.

[lua]function popTheWeb (event)
webView = native.newWebView( 0, 0, 320, 200 )
webView:request( “http://www.anscamobile.com/” )
end

function webSliceGo (event)
webView:removeSelf()
webView = nil
end

webLaunchButton = display.newRect( 200, 400, 50, 50 )
webLaunchButton:setFillColor(140, 140, 140)
webLaunchButton:addEventListener ( “tap”, popTheWeb )

webBackButton = display.newRect( 50, 400, 50, 50 )
webBackButton:setFillColor(255, 255, 255)
webBackButton:addEventListener ( “tap”, webSliceGo )[/lua]
[import]uid: 96383 topic_id: 21092 reply_id: 321092[/import]

yes it crashes. not stable [import]uid: 96683 topic_id: 21092 reply_id: 83381[/import]

But… really? That means newWebView is unusable ever. I must be doing something wrong. [import]uid: 96383 topic_id: 21092 reply_id: 83383[/import]

It doesn’t mean “it is unusable ever” - it means it is a new feature in daily builds that we will not guarantee will work.

It takes time to get features working perfectly and daily builds are not guaranteed.

Peach :slight_smile: [import]uid: 52491 topic_id: 21092 reply_id: 83499[/import]

Hey Peach, forgive the hyperbole. The implementation I’m attempting just seemed so straightforward that I assumed (and still do, can you confirm?) that I was doing something wrong, not that the feature is actually irretrievably broken, daily build and all.
[import]uid: 96383 topic_id: 21092 reply_id: 83586[/import]

Uhm oddly enough I just built this code and ran it on the Xcode simulator and could open and close the popup multiple times without any issues however yes, it’s crashing on the iPhone.

I’ll try to find out where we are at with it in our next meeting.

Peach :slight_smile: [import]uid: 52491 topic_id: 21092 reply_id: 83705[/import]

Thanks for looking Peach. I’m just getting my feet wet with all this programming biz so it’s a relief to know I’m not crazy :slight_smile: [import]uid: 96383 topic_id: 21092 reply_id: 83784[/import]

No worries; I’m sure it will be resolved soon :slight_smile:

In any case, it was the first time I’d tried it on device and, until the crash, I thought it was very neat! So thanks, I wouldn’t have checked it out yet if not for you :slight_smile: (Been too busy learning about GC.)

Peach :wink: [import]uid: 52491 topic_id: 21092 reply_id: 83896[/import]

Really hope a fix comes out soon! Web popups are not working for what I need, however this is. At least in the Xcode simulator. Please get this working!!! Thanks. [import]uid: 7710 topic_id: 21092 reply_id: 84151[/import]

fix fix fix [import]uid: 96683 topic_id: 21092 reply_id: 84327[/import]

Did anyone submit a bug report for this? [import]uid: 7710 topic_id: 21092 reply_id: 84475[/import]

The bug was fixed in the latest Daily Build, 736. There still is a crash problem if you try to remove the webView while a page is still loading but opening the webview and waiting for the page to load before removing is now working. [import]uid: 7559 topic_id: 21092 reply_id: 84476[/import]

Tom,

Thanks for the update. I will test it out shortly. [import]uid: 7710 topic_id: 21092 reply_id: 84479[/import]

Tom,

Just rebuilt for Xcode simulator and for device. I rarely crash now, once every 10 site taps, but the web site only came up once, and then crashed the app. The remainder of the times I try to pull up a site, I get a spinning circle, and the web view closes.

On the device, I get the same thing, and also it may just go to a grey screen after the spinning, or straight to the grey screen. Only once on the device did it pull up a site.

Thanks for the work so far. Hopefully we will get further as time goes on. [import]uid: 7710 topic_id: 21092 reply_id: 84511[/import]

I’ve been playing with the webView API and do think it needs more work. I’m not seeing it crash that often and it does load web pages when you construct the URL correctly. It works with http://www.anscamobile.com/ but not with http://anscamobile.com/ or http://www.anscamobile.com. The last two URLs just bring up a gray window.

Also, the test code example needs some locks added or it will crash.

[code]
local webView

function popTheWeb (event)
if not webView then
webView = native.newWebView( 0, 0, 320, 200, webListener )
webView:request( “http://www.anscamobile.com/” )
end
end

function webSliceGo (event)
if webView then
webView:removeSelf()
webView = nil
end
end

webLaunchButton = display.newRect( 200, 400, 50, 50 )
webLaunchButton:setFillColor(200, 200, 0)
webLaunchButton:addEventListener ( “tap”, popTheWeb )

webBackButton = display.newRect( 50, 400, 50, 50 )
webBackButton:setFillColor(0, 255, 255)
webBackButton:addEventListener ( “tap”, webSliceGo )
[/code] [import]uid: 7559 topic_id: 21092 reply_id: 84526[/import]

Tom-

Thanks for the quick reply. I will tweak the URL’s and see if that gets me through! [import]uid: 7710 topic_id: 21092 reply_id: 84528[/import]

Tom-

With doing that, I was able to pull up the sites!!! Now we just need people to do something to allow us use the links on those pages.

The pages come up fine, but the links don’t work. [import]uid: 7710 topic_id: 21092 reply_id: 84533[/import]

Jeremy,

Build 737 addresses the crash problem and looks pretty stable from my testing.

There still is an issue where sites don’t load if the URL is not correctly formed. It needs to be:
http://www.anscamoble.com/
The “www” and the ending slash is needed or it won’t load the page.

What do you mean about allowing links on those pages? Are links on web sites not working? The links on the anscamobile.com page work in webView.

Update: Can you provide a example URL that is not working? [import]uid: 7559 topic_id: 21092 reply_id: 84650[/import]

Hi Tom,

What about for a local file, I don’t seem to be able to get it to show, works fine with the older builds that cause crashes, it’s a pdf if that makes a difference,
I have tried the following with no luck

pdfview:request( "file:///test.pdf/",system.DocumentsDirectory )  
pdfview:request( "test.pdf",system.DocumentsDirectory )  
pdfview:request( "file://test.pdf/",system.DocumentsDirectory )  
pdfview:request( "test.pdf/",system.DocumentsDirectory )  

Thanks,

Jeff [import]uid: 100222 topic_id: 21092 reply_id: 84918[/import]

Tom-

Strange. You say you are able to click on the links inside of pages using newWebView, but it doesn’t work for me. I just changed one of my links to go to your site.

local webView = native.newWebView( 0, 0, 320, 436)  
webView:request("http://www.anscamobile.com/corona/")  

This code was typed in, and not copy and pasted.

This will bring up the page, but I still can’t tap on a link and go anywhere.
If I hold down on a link, it will ask if I want to open, copy or cancel. If I tap open, it does nothing.
If I tap on the menu choices at the top, it will do the drop down, but not go to that page.

Also, I am running Build 737. I will try later with one of the newer builds. [import]uid: 7710 topic_id: 21092 reply_id: 84991[/import]