[HTML5] Including SWF library causes "Invalid field access: length" exception

To test how OpenFL handles swf’s assets in the latest version (5.1.3), I’ve decided to create a completely new project in HaxeDevelop and added two things to it:

  1. This one line to project.xml: < library path=“assets/library.swf” preload=“true” generate=“true” />
  2. And this swf file at ‘assets’ folder: https://drive.google.com/file/d/0B1a88FGZUequVW1xc0U2QXp2TlU/view?usp=sharing

With this, the project fails to build when targeting html5.
I am not sure if this changes anything, but this SWF file has been created by extracting it from SWC file, which was compiled by Flash Pro CS6.

Upon further inspection I’ve discovered that executing command: “openfl process assets/library.swf” throws following exception:
Called from ? line 1
Called from Tools.hx line 558
Called from Tools.hx line 595
Called from format/swf/exporters/SWFLiteExporter.hx line 51
Called from format/swf/exporters/SWFLiteExporter.hx line 84
Called from format/swf/exporters/SWFLiteExporter.hx line 800
Called from format/swf/exporters/SWFLiteExporter.hx line 819
Called from format/swf/exporters/SWFLiteExporter.hx line 538
Called from format/swf/exporters/SWFLiteExporter.hx line 839
Called from format/swf/exporters/SWFLiteExporter.hx line 429
Called from format/swf/exporters/SWFLiteExporter.hx line 823
Called from format/swf/exporters/SWFLiteExporter.hx line 272
Called from openfl/display/BitmapData.hx line 680
Called from openfl/utils/ByteArray.hx line 629
Called from openfl/utils/ByteArray.hx line 225
Uncaught exception - Invalid field access : length

Does anyone have any idea what might be causing this?
I suspect it might have something to do with the size, since removing some elements from the swf file fixes the problem. However, this is not a solution I am looking for, since I was planning on including even bigger swfs (around 50MB).

I tried it out, and it is working for me on HTML5

I looked, and it appears that processing this SWF is taking around 225 MB of memory when it runs here. I’ll look and see if there’s ways to reduce the memory needed during the SWF processing step :slight_smile:

How can this be? I have freshly installed Haxe & OpenFL, with completely empty project. Are you doing anything special to compile it?
Also, 225MB doesn’t seem like a lot, especially considering I have 8GB of RAM. Memory should be an issue, I think.

It is possible that image.encode ("png") is returning null on your system for some reason, but its strange that this would be the case.

What version of Haxe, Lime and Windows are you using?

Everything is in the latest version. Haxe 3.2.1, Lime 5.1.0, and I am testing this on Windows 10 Enterprise 64bit.

I tried the same project on a different OS (Windows 7 Home Premium 64bit with 16GB of RAM) and this time it throws:
Called from ? line 1
Called from Tools.hx line 558
Called from Tools.hx line 594
Called from format/SWF.hx line 21
Called from format/SWF.hx line 42
Called from format/swf/SWFRoot.hx line 18
Called from format/swf/SWFRoot.hx line 41
Called from format/swf/SWFRoot.hx line 184
Called from format/swf/SWFRoot.hx line 196
Called from format/swf/SWFRoot.hx line 256
Called from format/swf/SWFData.hx line 893
Called from openfl/utils/ByteArray.hx line 632
Called from openfl/utils/ByteArray.hx line 763
Called from haxe/io/Bytes.hx line 474
Uncaught exception - alloc.c(180) : out of memory

Can you tell how much memory is used?

Looking at Task Manager I see one "neko.exe"process taking around 2GB, on both Win10 and Win7.

Perhaps the newer version of Neko included with Haxe 3.4.2 does better. I have not seen memory use go so high on the SWF you shared :confused:

Is there a newer version than 2.1.0? Because that is the version I am testing this on, and as far as I know, neko hasn’t been updated since last year.

Just to be sure, I updated Haxe to 3.4.2 but it didn’t change anything.

Are you testing a simple project with only the one SWF (as you mentioned above), or is it larger, or with more SWFs? Thank you

At this point all I am doing is calling “openfl process library.swf” from the command line.
If I can’t process single SWF, there is no point in messing around with a project.

Thank you again for your patience and help. It appears to use only about 300 MB of memory on my system, but I’ll see what we can do to reduce the memory pressure when processing SWFs :slight_smile:

This is an important feature to me, and I’m sorry that’s its not working for you at the moment :frowning:

Its cool, I can spend as much time as it is need to solve this.
So what possible difference could there be between our setups? Are you processing this on a different OS?
Or, how about your version of Haxe and OpenFL? Are you too using Haxe 3.4.2 and OpenFL 5.1.3?

Also, if you using Windows perhaps you could zip your Haxe folder and send it to me? See if it makes a difference.