Flex Hero Gotcha: Application Freeze on navigator.popView and navigator.popToFirstView

I’ve been spending a lot of time in Flex “Hero” preview release since it was released Sunday evening. Overall it’s quite good, I’m very happy to have it, and I’ve been able to do what I need to with my pretty basic app.

I ran into a pretty disconcerting gotcha and I wanted to post it here in case anyone else happens upon this.

Symptom

You navigate back to a previous view via navigator.popView() or navigator.popToFirstView() and the application stalls without an error

How to Reproduce It

If you are using the Employee Directory from the sample apps as your jumping off point, the EmployeeDirectoryHome.mxml has a search box and button in the navigation area. That’s fine and the app runs.

[actionscript]

text="{SEARCH_TEXT}" focusIn="searchKey.text=''" enter="search()"/>

click="search()"/>

[/actionscript]

Move the search box and button into an HGroup and positioned it below the navigation. Suddenly any call to navigator.popView() will go into la la land and the entire app will freeze. No error is thrown. Eventually, if you’re running on a device, you’ll be prompted to kill the app or wait. Don’t bother waiting.

[actionscript]


text="{SEARCH_TEXT}" focusIn="searchKey.text=''" enter="search()"/>

click="search()"/>

[/actionscript]

Workaround

With the keen eye and assistance of Jason Hanson, we determined that the measuring and drawing of content in the actionContent and navigationContent must happen at a different stage than the rest of the visual children. The width of the TextInput was being calculated instead being set as a percentage, and it was removing that calculation that fixed the issue. So, changing the width to 100% causes the TextInput to “greedily”, as Jason would say, take up all available space left by the button and the app once again works just fine.

[actionscript]

click="search()"/>

[/actionscript]

I’ve logged a JIRA bug for this issue.

Hero is definitely prerelease and this is one example of where that shows up.

I highly recommend you check out the Shopping Cart Application for Web and Mobile to see more advanced solutions. Thanks Jason!


image


Categories: FlexAIRPermalink