Why reloading pure asset SWF with AIR sdk 3.6+ doesn't work?
Hi,
I have a game targeting iOS using AIR sdk that needs to load many swf assets from the disk (packaged with the game). When using AIR sdk 3.5, everything runs just fine. When upgrading the sdk to 3.6 or later (-swf-version=19, 20, 21), we ran into the following problems:
1) The packaging time (making the ipa file for iOS) passes from 15 minutes to 40+ minutes.
2) The game can't load any swf twice (ie. reload a swf).
The first problem is not a big deal. We only have to wait a little bit more. Our guess is that is has to do with new feature introduced by the sdk 3.6, which will go through all packaged secondary swfs and remove the code from it, and since we have lot of swf assets, it takes more time.
The second problem is way more serious, as I have to be able to reload assets according to player's action. Since we have a ton of assets, I can't keep them all in the memory as we could quickly run out of memory.
I know that there's a documented limitation of sdk 3.6 which states:
In AIR apps on iOS running in AOT mode there is a problem when a SWF is reloaded. Therefore reloading a SWF will not be allowed for AIR apps for iOS in AOT mode and attempting to do so will result in following error:
Error 3764: Reloading a SWF is not supported on this operating system
It also says that "Reloading of pure asset SWFs will work with AIR 3.7". However, that's not true, since all my assets are pure asset SWF without any code inside. It won't work, even with AIR 3.8.
While searching on the internet, I came across a forum post that says that the only way to know if a swf is a pure asset swf, is by using swfdump.exe, and searching for the DoABC2 tag. I did it, and effectively, DoABC2 tag was there, but empty.
So my first observation is that:
- Pure asset SWF file containing empty DoABC2 tag can be reloaded using AIR SDK 3.5
- Pure asset SWF file containing empty DoABC2 tag can't be reloaded using AIR SDK 3.6+
It seems to me that AIR SDK 3.6+ doesn't care if the tag is empty or not. If it is there, then it's not ok.
Then I wanted to know why my SWFs have this empty tag. After lot of tests, it turns out that it is because I am using jsfl to automate the export of assets from a FLA file. And there comes my second observation:
- When exporting a swf without code from Flash IDE (Ctrl+Alt+Shift+S), there's no empty DoABC2 tag.
- When exporting a swf from the Flash IDE's library (right click on the library Movieclip -> Export Flash movie...), empty DoABC2 tag is automatically inserted.
Unfortunately, my jsfl script uses thee same Library export functionality, and it produces the same "contaminated" swf. Why doesn't it produce the same SWF from both ways of export? I have no idea.
In the perfect world, the AIR SDK would not only look for the DoABC2 tag, but it should check whether if there's code inside. Also, Flash should use the same export process disregarding if it is being called from the IDE or the Library, and not inserting empty DoABC2 tag when there's no code.
As for now, I can't find any workaround to solve my problem. That means that I'm stuck with swf-version=18, and I can't benefit from all the cool features such as rectangle textures, new Context3DTextureFormat etc.
If anyone has a solution, or simply pointing out what I'm doing wrong here, please share it.
Thanks for reading.
Iojeirg
