VerifyError out of the blue. Help! - actionscript-3

I'm the developer of ShellShock Live, a free online artillery game:
http://www.newgrounds.com/portal/view/564049
Everything has been running smoothly, but every once in a while for a period of 4 hours or so, hundreds of "VerifyError: Error #1026" will show up in my error log. Then, they will stop.
I looked into VerifyError and found that "The VerifyError class represents an error that occurs when a malformed or corrupted SWF file is encountered." The SWF on Newgrounds is just small loader SWF that loads the full game SWF from another site, so there must be a problem there. I'm stumped, because the game will run fine for days, and then just start getting these errors out of the blue, after no changes to either SWF.
ShellShock has hundreds of players online at any given moment, so I would like to fix this ASAP. Any help would be appreciated! Thank you!

I know the original post is a couple of years old but since I've just spent many days trying to work around a similar issue, and since this thread does not contain what I believe is the correct explanation I'll post the conclusions of my own investigation here, for anyone else to use:
The VerifyError events are almost certainly being logged because the loader SWF on NewGrounds targets a lower Flash Player version than that of the game SWF that causes this error.
The Flash Player on the user's system will accept the NewGrounds SWF loader because it targets a version equal to or lower than the version installed. After that, an external SWF that targets a higher Flash Player version can be loaded without any complaint from the Flash Player, unless it tries to access unavailable features in that Flash Player, and then it will throw the VerifyError.
The sporadic nature of this problem, in 4-hour surges, is likely related to the different penetration of later Flash Player versions in different parts of the world (and hence different time zones). During very active periods of casual gaming (weekends and evenings?) in countries with low penetration of recent Flash Player versions you will likely see batches of these VerifyErrors logged.
The bad news is that after many days of trying to find a workaround for this very problem we have been unable to find any way to catch the VerifyError. It does not even get caught by an UncaughtErrorEvent handler!
The only thing I can suggest that might help in your case (not mine, unfortunately) is to determine the target version of the NewGrounds loader SWF (check the 4th byte in the SWF) then do one of the following :
Compile your game to target the same version of Flash Player as the loader targets. That way you can be sure that if the NewGrounds loader SWF is successfully loaded into the user's Flash Player your SWF will also work in that version without problem, or
In the initialization code of your game, check the Capabilities.version to determine the Flash Player version installed on the user's system and use that to branch control so that advanced Flash Player features are only used in appropriate Flash Player versions.
In my case I have access to the loader code, but not the code of the thousands of SWFs it loads. Since the external SWFs are stenciled into copies of the loader SWF as ByteArrays I can check the SWF's Flash Player target version byte (byteArray[3]), and compare it to the installed Flash Player 'major.minor' version obtain from Capabilities.version, but since SWF Flash Player target version bytes are (currently) incremented with every minor version increment of the Flash Player, it is impossible to map the SWF target byte (byteArray[3]) to future Flash Player 'major.minor' versions, until we know what the maximum minor version number of the current Flash Player will be.
Hope anyone else encountering this will have better luck than we did.

I think it may be a flash player error, try disabling any graphics acceleration or caching. It may be helpful to figure our what graphic card they are using.
Have you made changes to your socket server? Are you using like smarfoxserver?

I had this error in a very small project with cs3 flash9. So I was able to track this error down.
NOTE: this error is emitted incorrectly. The reason the error was emitted in my project was NOT because of a faulty swf because I do not import any swf into my project.
REASON:
I had a code line written like this:
_mc.my_counter && _mc.my_counter--;
SOLUTION:
I changed the line to this:
if(_mc.my_counter) _mc.my_counter--;
... and the verify error message was gone as fast as it appeared. Looks like this is a real as3 bug.

Related

problem:Website and Flash loading an older version of my SWF client

I have a swf game client that's being hosted on my website. Users mostly use flash projector to connect directly by opening the swf's url.
My problem is that, when I upload a newer version of this swf client on my website, the users still manage to load the older client, that is no longer there. older and newer clients had the same name, but I want to keep it that way.
I would appreciate any suggestions :=)
Like Organis's comment, here is one way to work out.
Your game will start from index.swf, and index.swf did't contain any game logic,its only job is to get the version number from index.html(use loaderInfo.parameters) and load the main game swf use the version num

GameInput API doesn't work once the SWF is embedded in a HTML page

I've built a small demo application to test the GameInput APIs that Adobe released a little while ago. It works perfectly in debug mode, via the .exe and via the .swf that get generated via Flash CC, but when I test the application embedded on a web page, I can no longer use the controller (I am using an Xbox 360 Controller).
I've spent some time researching, and can't find any references to the GameInput classes either working or not working when the SWF is embedded on a web page.
Does anyone know if it is possible to get working (perhaps via some extra data in the HTML embed code) or whether this is an obstacle I won't be able to get around?
The GameInput classes absolutely work in the browser. Support has been there since Flash Player 11.8 (in beta), then officially added with 11.9.
It does come with some caveats:
Not all devices work; some fringe devices may get ignored by Flash.
Sometimes the addition of devices that are supported don't really work - you may have to disconnect and reconnect them to get them to work.
Sometimes when using multiple controllers of the same type they get mixed up and only one of them will work.
Actual reported control ids vary between the Plugin/ActiveX version of Flash (Firefox/Safari/IE/etc) and Pepper (Chrome).
You usually need to press a button with the proper SWF focused for the GameInputDevice to be detected and reported.
An XBox 360 controller is guaranteed to work. That's FP's main "target", if such a thing exists. I have personally performed dozens of tests with different devices and the (wired) XBox 360 controller is the only one that never gave me any headache.
I have a published SWF that works for testing which devices have been properly detected, and their reported controls, with source code available as well.
As a final note: as is the norm with any HTML-embedded SWF, be sure to always test in a server, not using file:///. A local server with XAMPP or whatever will do. Loading SWF content without a server always gives you a lot of restrictions that you have to circumvent and it's generally more effort than it's worth. I wouldn't be surprised if GameInput support was unavailable for SWFs loaded from file:/// on some given browser.

My Sound object is using to much memory and causing my application to crash. How can I empty the first half of the objects data?

I'm currently working on a dynamic MP3 player in AS3. The player will also support continuous (in length) radio streams.
Because my player will include a 'seek' bar, I allow the user to seek through the Sound object's data. Now I know that with a continuous stream, data being stored on the users RAM will never stop, as downloading will never stop on a continuous stream. This means, after a few hours of streaming, allot of RAM is being used by my app. I've tested the app on my own machine, running a very high spec, and the app crashes in my browser. When i say the app crashes, I mean the whole of Flash, meaning I have to restart my browser in order to use Flash again. I know my app is the cause as Flash has never crashed in the past. It only does it when my app has been streaming for 2+ hours.
So what I want to do is only allow the user to cache up to an hours worth of audio. After an hour, I want to clear the first half of the sound objects data, meaning that only the most recent half hours audio is stored and available for seeking.
So I have my stream:
var soundObj:Sound = new Sound();
soundObj.load(new URLRequest('stream.mp3'));
//ect ect
and sound is where the data is stored. So my question: How would I clear the first 30 mins of audio from that object?
Perhaps the Sound class is not meant to reliably play "unlimited" MP3 files, which seems to be your case. It is made to play normal MP3 "songs". Two hours of MP3 sound can easily accumulate to be larger than 200 megabytes of data.
But there is a good solution - use NetConnection and NetStream classes to stream audio instead. There are many tutorials out there. You will also be able to stream your MP3s, just a bit differently - a central server will be involved, which will transcode these MP3s on the fly, delivering it to you in a true "streaming" manner. One of such servers is Adobe Flash Media Server, an overpriced piece of work from Adobe. A lot of free and open-source alternatives exist which will work fine for your purposes - Red5, nginx-rtmp to name a few, that I have tested myself.

Sound latency in AS3

I am triggering short sounds dynamically from the library for a game (Specifically Air for Android). When the user clicks a button the sound can take up to 600ms to actually play.
I have set it for any silence before the actual sound by calling the sound like so:
private var channel:SoundChannel = new SoundChannel();
private var buttonClickSound:Sound = new button_click();
public function buttonDownClick() {
channel = buttonClickSound.play(63);
}
Still getting a ridiculous amount of latency.
Things I have tried:
converting MP3 to wav
placing Sound Clip in the timeline
calling Sound Clip from urlLoader
All return the same results. I know there are threads here that talk about this but none have offered a real solution that I can find. Is there no way to cache the sound or store it in a buffer?
Thanks for looking.
Important update
The flash CS5 AIR for android functionality was never out of beta. And sadly as adobe is famous for, the functionality has been discontinued for flash CS5 so that the full working/updated version will become a selling feature for CS6 or CS5.5. I have many, many feelings about this as a customer who has spent literally MANY THOUSANDS of dollars on adobe products but I'll keep this about information and not my burning rage towards adobe feelings. For proof of this see:
http://labs.adobe.com/technologies/flashpro_extensionforair/
So it is most likely that this is one of many bugs left unfixed in AIR for android in CS5. This is not a surprise, as when I bought CS4 master collection which promised AIR 1.5, even AIR 1.5 was left broken and all bug fixes were rolled into 2.0, which was only available for CS5. One of the biggest bugs they never fixed in CS4 AIR 1.5 was a major, crippling bug in webkit which nearly rendered any use of webkit in AIR non-functional. In fact when I worked for Webkinz.com, a major project was completely thrown out the window and I was actually ridiculed for proposing using AIR, touting all it's amazingness and then left looking like an idiot in front of all my peers when these bugs appeared. Literally I'm not kidding the head of my 180+ developer division centered me out in a meeting around a gigantic table with every major player in that company.
Anyway perhaps my update did bleed into somewhat of a rant but it's good information I think and a good lesson to be learned, which is always assume the worst with Adobe products. Fortunately, as mentioned in my answer, it's not a dead end and there are ways around their "business model."
Original Answer
It's a bug in AIR for Android:
http://forums.adobe.com/thread/753977
That post is dated, but I've seen several more around the same time frame and enough that I'd call it a fact. Have you updated flash CS5? ( Go to Help->Updates). To be honest I don't even know if they have patched/addressed this bug yet but your best bet of finding out is to grab the very latest Flex SDK and try manually packaging your SWF into an APK using it. Instructions:
http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac25d3d8c712b2d86751e-8000.html#WS901d38e593cd1bac25d3d8c712b2d86751e-7ffb
More detailed/tutorial-like instructions:
http://thulasiramsoft.wordpress.com/2011/01/16/build-apps-for-android-using-as3-without-a-device-using-flex-air/
If this is a bug this is where you're going to see the fix appear first. Try packaging your SWF into an APK manually using the above methods and ensure you've updated the AIR for android on the device to AIR 2.6 (latest, just go to the market to update). This will either fix the problem or eliminate it as a possibility both on the compiler and runtime side.
Sound latency is a bug in Flash exporting to AIR.
Easy way around is to make some background music playing, then sound device doesn't go to sleep. If you don't want music you can make some silent sound playing forever. This solves the problem with sound delay for other short sounds.
[Embed(source="sfx.mp3")]
const snd_sfx:Class;
const sfx:Sound = new snd_sfx();
const SilentSoundTransform:SoundTransform = new SoundTransform(0);
function playSoundSilentlyEndlessly(evt:Event = null):void
{
sfx.play(0, 1000, SilentSoundTransform).addEventListener(Event.SOUND_COMPLETE, playSoundSilentlyEndlessly, false, 0, true); // plays the sound with volume 0 endlessly
}
playSoundSilentlyEndlessly();

Load-completion order affects swf code in Air 1.5 on PC only

Very strange one.
Our air application loads multiple swfs, which together make up a lesson.
If we load them serial, rather than parallel, the code inside all swfs is broken. (There's a previous stackoverflow q on this issue). If they are loaded in parallel all timeline top level code works.
On Mac, all code works, including deeply nested code inside MCs inside MCs, all the time, regardless of the order in which loading of the swfs completes and inits.
On PC, top level (of each swf timeline) code always works, but deeply nested code is only running dependent on the order in which the loading of the swfs completes and inits.
Referring to the swfs as A,B,C and D, if the init order is A,B,C,D then code in swf A (deeply nested code only) does not function - even stop() is not working. This only happens on PC.
If the swfs init in the order B,A,C,D or even C,B,A,D then everything is as it should be. (It has been a fairly long process identifying this pattern!)
On occasion more than one loaded swf is having problems - I haven't been able to spot an obvious pattern behind this.
All 4 swfs run fine as stand-alones. All 4 swfs run fine in the Mac version. All 4 swfs should be loading into their own application domain as Air doesn't permit anything else, and the application domain is also being specified as a new domain each time. There are no detectable domain problems - no errors are being thrown.
Clearly something is borked. I don't believe the borked thing is in my code, as the application functions perfectly on Mac, and is only broken dependent on load complete order in the PC version, and only deeply nested code is borked.
The items which are borked (MCs with non functioning code) are not exported in the library as symbols.
Has anyone come across this, or anything similar to it?
Some variations I will experiment with:
1) Exporting the symbols for MCs with code in the library so that they load in frame1 (before the init event fires) even though they don't need this.
2) Not manually specifying the application domain but letting it default (to the same value)
I'll document my findings here. Can anyone think of anything else worth varying to see if there's an impact?
I think I've found the source of the problem.
The load order and the broken movieclip code are both symptoms of the same problem: the swf has not loaded into memory correctly.
The broken swfs are usually the largest, and when they INIT ahead of much smaller swfs it's probably a sign of incomplete loading, hence the correlation with Level-1 code not running. (Level-0 is timeline, level-1 is code inside MCs on that timeline etc).
Having run the tests hundreds of times I've found that this problem occurs approximately 50% of the time in a Parallels-XP virtual PC, and occasionally on a Windows 7 machine that has been down-versioned to windows XP (and hiccups in many other areas). So far it does not happen on a Mac book pro bootcamp XP install, or a stable Vista install.
I guess it's a genuine thread crash in the Air app, most likely some sort of memory issue?
I have not been able to find a way to prevent the problem from happening. Instead I have a work around:
Each swf contains a MC on the timeline on frame 1 with a line of code with the sole purpose of notifying the application (via the sandbox bridge) that level-1 code has been loaded correctly. If this notification is not received for a particular swf by the time the 'COMPLETE' event fires, the swf is deemed to have loaded incorrectly, and is unloaded from memory and loaded again.
This process is repeated until the load is correct. The files are local so the delay to the user is minimal.