Skip to main content
Inspiring
June 6, 2011
Question

StageWebView crashes Adobe AIR on iOS when assigning it a stage

  • June 6, 2011
  • 2 replies
  • 4568 views

I'm having a problem with StageWebView on iOS (in Android it works fine). More exactly, It's an iPad app.

I'm loading a dynamic PHP URL with StageWebView's loadURL method, and then I start building Flash interface elements in a left column (the StageWebView browser is in the right column), which works fine, then I wait a couple of seconds for the page to load (with a Timer), and then I finally show the browser to the user with:

this.webView.stage = this.stage;

The moment I run that line, the whole iOS application crashes and the iPad goes back to its desktop (I suppose that should never happen in Adobe AIR no matter what you do).

But the process is still in memory, since if I double click the iPad physical button, I can see my application icon in the running apps bar (though if I click the icon, the app starts from the beginning, instead of resuming).

Using AIR 2.6. Any ideas on how to solve this crash?

Thanks.

This topic has been closed for replies.

2 replies

Participant
July 27, 2011

You tried to use systemManager.stage?

this.webView.stage = systemManager.stage;

Participating Frequently
June 6, 2011

Hi,

#1

I'd check 2.6 release notes: see section "StageWebView":

http://kb2.adobe.com/cps/891/cpsid_89107.html

as it describes differences between iOS/Android implementation (they are subtle but worth of checking I think)

#2

there is Event.COMPLETE supposed to be fired when your web page is loaded after location is changed/set. So you could use it in place of timer I think.

regards,

Peter

OMA2kAuthor
Inspiring
June 6, 2011

Thanks for the link. I've checked it, but the differences listed are not relevant in my app, I think.

Yes, I know there is also the "Event.COMPLETE" event, but I can't use that because it only fires after the page is fully loaded, with all its images, and the page I'm trying to load has 200 images or so and takes almost a minute to load, so I can't have the user wait that long. I just want to wait until the HTML has loaded.

Anyway, I've also tried Event.COMPLETE and after the long wait, the app still crashes when trying to show the StageWebView.

I've even tried a complex solution, by using StageWebViewBridge by Pedro Casaubon to communicate with the JavaScript in the page, using JavaScript's "DOMContentLoaded" event, so it fires as soon as the HTML (but not the images) has loaded. That works, but as soon as I make the StageWebView visible by assigning it the stage, AIR crashes!

So, AIR crashes when trying to assign the stage to the StageWebView object in all these three cases:

- After waiting for AS3 Event.COMPLETE event listener added to loadURL()

- After waiting for JavaScript "DOMContentLoaded"

- After waiting for a fixed period of time set with a Timer event

The only way AIR doesn't crash when assigning the stage to StageWebView is NOT waiting at all. That is, running the loadURL function and immediately running the "this.webView.stage = this.stage;" line to show the StageWebView object in the stage. In that case it works, but it shows some ugly white box in the StageWebView area while loading, which I was trying to avoid, plus JavaScript events don't work until the page is loaded.

All those crashes described above are most likely a bug in Adobe AIR, but I don't know how could somebody else reproduce it since it could be caused by anything (the dynamic PHP page I'm loading, the JS code, something in the AS3 code, though I don't think that code has anything out of the ordinary...)

Also, when I test the app with ADL in the PC, everything works as expected. The crashes only happen in the iPad (it's an iPad 2).

Participating Frequently
June 6, 2011

Hi,

(note: I don't have iPad yet).

People are hiding/showing stage web view instance by:

- set stage property to display object stage to show it on screen

- set stage property to null to hide it from screen - when page loads set stage property again to display object stage

You could find it in various places, e.g.:

http://soenkerohde.com/2010/11/air-mobile-stagewebview-uicomponent/

where hide/show feature is required.

Maybe that would allow you to implement expected functionality,

regards,

Peter