Skip to main content
sinious
Legend
May 25, 2012
Question

Sudden error I can't find and StageWebView (AIR for iOS)

  • May 25, 2012
  • 3 replies
  • 1637 views

Hey all,

In my app I allow a user to download files from a list and then typically use StageWebViews to display them (videos mostly). Recently my app started to misbehave.

I'm using Flash Builder 4.6 with AIR 3.2 on Win7 Pro 64.

I test on-device. I choose fast export (quick packaging) and debug right from Flash Builder so I can see traces/errors/etc from the iPad.

After downloading a ~40MB MP4, I save it to the applicationStorageDirectory (and mark it 'do not back up'). I then wait 3 seconds just to be sure the write has a few seconds to complete. Then I black out the screen with a black sprite, stick a close button on the screen and load the video into a new StageWebView.

The problem is the first time these larger 40MB videos are saved and attempted, TONS of code isn't firing off or affecting the display. The video plays just fine, centered on the screen. However all the code to remove tons of things from memory during video playback which has tons of trace statements sprinkled in is simply not affecting the iPads display. This ONLY happens on iPad1 (OS 5.1). iPad2 and iPad3 work just fine.

I presumed I was being too aggressive with the iPad1 and added more and more time between downloading, saving and setting the bit on the file so the iPad1 wasn't innundated with doing to much at once. I can add 25 minutes worth of setTimeout between playing this video for the first time and it will fail every time though. So it's not being innundated.

If the video is already downloaded and a user selects it, it works perfectly fine. All views/classes are disposing properly to free up as much ram as possible for the video playback.

Now, I'm getting this error randomly:

Error #2044: Unhandled ErrorEvent:. text=Plug-in handled load

I can't find where this is coming from. Has anyone seen this before? I don't know if it has anything to do with what I'm seeing fail here. I doubt it because I get it a very short time (few seconds) after the video starts playing back. I only get this video the first time a file is downloaded and played but then never again.

I have an UncaughtErrorEvent that isn't even catching this. Everything to do with the class that displays the video has try {} catch() {} blocks over every line of code. So doesn't the small file downloader class. Nothing is throwing an ErrorEvent.

Is there any easy way to find where this error is being generated? Something I might not know about the Flash Builder Debugger? Other errors show up and tell me where they occured, but this brand new error does not cause the app to fail and the debugger doesn't even flinch at it.

On the first part, has anyone recently seen their apps exhibit something like this? I have a list of files that I destroy before I show the video and it continues to exist even though I literally trace() all over the code that should destroy it and I see the traces. Everything is nulled. Objects no longer exist. The background isn't visible that I'm tracing as I build and it exists on the display list. It's very odd.

It'd just like suddenly StageWebView has an issue loading a freshly downloaded and saved file. It nukes the display list, nothing I do to it matters. But if the file already exists it all works fine.

This topic has been closed for replies.

3 replies

Inspiring
May 30, 2012

"After downloading a ~40MB MP4, I save it to the applicationStorageDirectory (and mark it 'do not back up')."

Doesn't this step require a native extension? Have you tried it without this step (marking the files)? Just a shot in the dark, but maybe try saving to a different location other than the ASD? (just for trouble-shooting, to see if they work)

This is concerning. My app will be incorporating >20MB file downloads with StageWebView too, though I haven't got to coding that portion yet. Please let us know what you find out.

sinious
siniousAuthor
Legend
May 30, 2012

Yes I use ie.jampot.nativeExtensions.MobileBackup. Worked perfectly fine before and continues to return a true Boolean value for success and Apple has never rejected the app. They initially did because I did not set the backup bit. I presume that means it's working just fine.

This app crashes after that code happens, during trying to load the content into a SWV. But hey, why not, I'll disable that and we'll see what happens. I'll report back. I get no errors at all when the app crashes (when I fast build for debugging and test on device). No errors at all. It just crashes. That's.. not good.

edit:

Nope sorry, didn't change a thing. The second time I use URLLoader after properly disposing of it each time it fails on any large files and the app crashes with no info back to Flash Builder. Even with MobileBackup disabled completely. Sucks.. Flash Builder profiler is showing me the reference counts on objects and I can see I'm cleanly disposing of everything properly.Something won't leave memory even though all reference counts are 0. This does NOT happen on iPad2 or iPad3, just iPad1 past OS 5.1. Ugh...

re-edit:

After profiling like crazy, tracing like crazy, crossing all my T's and dotting my....... lowercase j's...... I can only conclude there is now an intolerance for MP4s being played in a StageWebView of a certain filesize. YMMV but just making a quick demo app, downloading a 44MB MP4 and playing it works fine the first time. I then dispose of everything and verify it in profiler. I even run garbage collection manually on the profiler and it still curiously has a lot more memory in use than what it had at app launch. All instance (reference) counts are 0. Curiously memory is still pretty close to the same amount as the video I just played regardless that I disposed of the SWV instance completely. It's like the dispose isn't working. My method of dereffing the class level private variable is:

_swv.stage = null;

_swv.viewPort = null;

_swv.dispose();

_swv = null;

This doesn't seem to release the memory as fast as I'd like to see. Perhaps there's something lingering but that should properly dispose of that SWV instance.

Upon downloading the second video, the very second it's finished downloading (via binary mode URLLoader) the app crashes. It doesn't even fire off a complete event or error in any way, the app literally just quits. Perhaps the previous 40MB video is somehow still lingering and once I have that 44MB video in mem and try to load a different 40MB video it's 40+44=84MB ram trying to be allocated. I can't see why because as above, I'm disposing of the SWV. Reference counts of _swv is 0 after the first video is played and closed.

Really strange but be careful, something new is going on here. It used to work perfectly fine. It appears to be an issue since 5.1. Perhaps Apple caching the SWVs contents when it's not desirable to do so. I may have to go back and use StageVideo and draw up my own video controls. I only use SWV because both it comes with nice controls and a fullscreen built in that runs very smoothly. If it isn't broke, don't fix it.. Well.. it's broken.

I have verified that 20MB videos download and work fine. 40MB is giving me issues. Not sure where the line is here.

sinious
siniousAuthor
Legend
May 30, 2012

Geez I'm usually the one answering the questions but this appears to be rampant on iPad1 past the 5.0.1 update. Apps that worked perfectly fine before are now crashing left and right using the release AIR 3.2. As much as I can narrow it down to is URLLoader somehow dereferencing from memory even while it's being used and the app is in the foreground.

I'm not sure how that got screwed up but there's everyones warning. Anything I download over 20MB is now subject to a potential app crash. Flash Builder reports no errors and the same code works perfectly fine using AIR3.2 on iOS 5.0.1. Must be apple kicking Adobe in the nuts.