newWebView crash - short sample code

23 replies [Last post]
khincker's picture
khincker
User offline. Last seen 1 day 17 hours ago. Offline
Joined: 8 Oct 2011

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 )

Replies

iPlayalot's picture
iPlayalot
User offline. Last seen 2 weeks 23 hours ago. Offline
Joined: 10 Oct 2011

yes it crashes. not stable

khincker's picture
khincker
User offline. Last seen 1 day 17 hours ago. Offline
Joined: 8 Oct 2011

But.. really? That means newWebView is unusable ever. I must be doing something wrong.

peach pellen's picture
peach pellen
User offline. Last seen 1 day 12 hours ago. Offline
Staff
Joined: 12 Apr 2011

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 :)

khincker's picture
khincker
User offline. Last seen 1 day 17 hours ago. Offline
Joined: 8 Oct 2011

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.

peach pellen's picture
peach pellen
User offline. Last seen 1 day 12 hours ago. Offline
Staff
Joined: 12 Apr 2011

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 :)

khincker's picture
khincker
User offline. Last seen 1 day 17 hours ago. Offline
Joined: 8 Oct 2011

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 :)

peach pellen's picture
peach pellen
User offline. Last seen 1 day 12 hours ago. Offline
Staff
Joined: 12 Apr 2011

No worries; I'm sure it will be resolved soon :)

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 :) (Been too busy learning about GC.)

Peach ;)

jeremymarx
User offline. Last seen 4 weeks 5 days ago. Offline
Joined: 21 Jul 2010

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.

iPlayalot's picture
iPlayalot
User offline. Last seen 2 weeks 23 hours ago. Offline
Joined: 10 Oct 2011

fix fix fix

jeremymarx
User offline. Last seen 4 weeks 5 days ago. Offline
Joined: 21 Jul 2010

Did anyone submit a bug report for this?

Tom
User offline. Last seen 8 hours 44 min ago. Offline
Staff
Joined: 13 Jul 2010

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.

jeremymarx
User offline. Last seen 4 weeks 5 days ago. Offline
Joined: 21 Jul 2010

Tom,

Thanks for the update. I will test it out shortly.

jeremymarx
User offline. Last seen 4 weeks 5 days ago. Offline
Joined: 21 Jul 2010

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.

Tom
User offline. Last seen 8 hours 44 min ago. Offline
Staff
Joined: 13 Jul 2010

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 )

jeremymarx
User offline. Last seen 4 weeks 5 days ago. Offline
Joined: 21 Jul 2010

Tom-

Thanks for the quick reply. I will tweak the URL's and see if that gets me through!

jeremymarx
User offline. Last seen 4 weeks 5 days ago. Offline
Joined: 21 Jul 2010

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.

Tom
User offline. Last seen 8 hours 44 min ago. Offline
Staff
Joined: 13 Jul 2010

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?

jeff.wesson
User offline. Last seen 3 hours 2 min ago. Offline
Joined: 26 Oct 2011

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

1
2
3
4
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

jeremymarx
User offline. Last seen 4 weeks 5 days ago. Offline
Joined: 21 Jul 2010

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.

1
2
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.

Tom
User offline. Last seen 8 hours 44 min ago. Offline
Staff
Joined: 13 Jul 2010

Jermey,

I'm seeing the same thing with links. I though it was working earlier.

jeremymarx
User offline. Last seen 4 weeks 5 days ago. Offline
Joined: 21 Jul 2010

Tom-

Thanks to you and your team! It's working great right now!
Thank you, thank you, thank you!

Tom
User offline. Last seen 8 hours 44 min ago. Offline
Staff
Joined: 13 Jul 2010

Jeremy,

We figured out the loading and link problem for remote web pages. The fix is in build 741. We are still looking at the local web page loading issue.

khincker's picture
khincker
User offline. Last seen 1 day 17 hours ago. Offline
Joined: 8 Oct 2011

Hey, it seems as though newWebView is broken again? When I try to use it I get an error:

attempt to call field 'newWebView' (a nil value)

This is using build 746. Using the same code, (original post), which was broken but then got fixed.

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.