Invalid BitmapData randomness
Asked Answered
B

1

6

I started converting this flex application to run on android using the new flex hero sdk. I already replaced all mobile-incompatible components and got it running a few times succesfully.

When I use the same libraries running the original webapplication it works perfectly.

The big problem however are these random Invalid BitMapdata errors while starting the mobile application. Here's the whole output.

ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData/ctor()
at flash.display::BitmapData()
at spark.primitives::BitmapImage/http://www.adobe.com/2006/flex/mx/internal::applySource()[E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\primitives\BitmapImage.as:1337]
at spark.primitives::BitmapImage/http://www.adobe.com/2006/flex/mx/internal::validateSource()[E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\primitives\BitmapImage.as:1652]
at spark.primitives::BitmapImage/commitProperties()[E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\primitives\BitmapImage.as:902]
at spark.primitives.supportClasses::GraphicElement/validateProperties()[E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\primitives\supportClasses\GraphicElement.as:3487]
at spark.components::Group/commitProperties()[E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\components\Group.as:931]
at mx.core::UIComponent/validateProperties()[E:\dev\hero_private_beta\frameworks\projects\framework\src\mx\core\UIComponent.as:8095]
at mx.managers::LayoutManager/validateProperties()[E:\dev\hero_private_beta\frameworks\projects\framework\src\mx\managers\LayoutManager.as:597]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\hero_private_beta\frameworks\projects\framework\src\mx\managers\LayoutManager.as:760]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\hero_private_beta\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1157]

I debugged many times and I found that when it reaches this method

mx_internal function applySource():void
{

in BitmapImage.as, at this statement

if (!bitmapData && tmpSprite)

the bitmapData == null. When I run the original webapplication however, bitmapData is not null. The bitmapData value should be determined in this line of code

<s:BitmapImage id="smallTriangle" smooth="true" source="@Embed('/com/xploreplus/components/containers/panel/assets/images/smallTriangle.png')" />

Now it seems to me that, wile running the mobile application, it is unable to find the image, as when I run the webapplication, using the same library where the above line of code is, it is able to find the image.

This problem has been haunting me for days now and I'm really starting to think this is a bug, especially because it sometimes DOES run. Or is there something I'm missing here.

Bashemath answered 23/2, 2011 at 12:20 Comment(4)
There were some bug fixes since the Hero Preview Release build from MAX that may have fixed this issue. Have you tried the latest Hero build? You can get the latest build by signing up for the prerelease program: iamdeepa.com/blog/?p=85Wilkins
Hi steven. I am currently using the MAX Preview (4.5.0.17689) build that can be found at adobe's download page for hero SDK because the later builds don't support mobile features. I signed up for the prerelease program a few days ago. Would being involved in this program mean that I will get the latest builds including the mobile features? Also have I temporarily 'fixed' the invalid bitmapdata error by removing my skinclasses everywhere, seems that the error was thrown by another problem. I haven't had the time to dig deeper into that. So the program runs now, but still without showing any imgBashemath
Unlikely to be your problem, but I've seen Invalid BitmapData error sporadically when: 1) A bitmap is too large. 2) When my application runs out of memory (allocating a BitmapData tends to push it over the edge) 3) And when trying to new up a bitmap data with an invalid size. I don't use Flex much but can you please include the code where you assign the bitmapData variable from the BitmapImage with id "smallTriangle?"Positivism
Use the release of Flex 4.5, not the preview. The latest SDK has a Spark Image class.Brachio
T
2

I'm almost certain this is a memory issue. The fact that the error is in the BitmapData constructor says that either the app is trying to create a BitmapData with invalid dimensions (not likely since it works in your other build and the image is fetched on compile time) or the most likely scenario that Flash has run out of memory and can't create the BitmapData (mobile devices usually have much less memory than a PC).

Transform answered 27/8, 2011 at 22:34 Comment(1)
This may be a job for a try/catch block - you may be able to get a better hold of what's happening if you can catch the error during runtime.Heading

© 2022 - 2024 — McMap. All rights reserved.