Archive for the ‘cubeia’ Category

Flash 10.1 breaks multiwindow applications

Tuesday, June 22nd, 2010 by fredrik

Adobe has made their Flash Player version 10.1 available for some time now. Among some more or less nifty features, they also have a new way of preserving CPU and resources when an application is out of view (different tab or minimized), the application is throttled to a meager 2 frames per second instead of about 60 frames per second.

The throttling effects everything in the application, Timers, Events, LocalConnections etc. The behavior is explained very well in Tinic Uro’s blog post.

I think I understand the rationale here. Currently, an application is running full speed even when it is out of sight from the user. This means that flash applications running on background tabs might eat up CPU without any real reason for it. Since Flash has been taking a lot of flak for this lately I can see how they are eager on improving this. The general idea behind this is sound.

However, my problem with this (and other companies as well)  is that you are breaking backwards compatibility. The throttling affects all timers and event handling. Any type of Flash application that uses multiple windows might use LocalConnection to communicate between the windows/applications. After all, that’s what it’s there for. If any of the participating applications are minimized or hidden, they will almost stop producing/consuming since they are throttled down to 2 FPS.

What is even worse is that you get no notification when this occurs. There are no callbacks or events triggered. Suddenly your application might be running at a 30th of the default speed and you will not be told about this. There is currently no option to avoid being throttled either. To me this is not acceptable if I am developing RIA:s. Imagine writing a desktop application in C++ where your timers suddenly could jump down from 60 FPS to 2 FPS. Without a callback. How would that go with the developer community?

Can this be fixed?

I think so. If Adobe only adds an opt out option for an application I think it would be fine. The default behavior could still be the throttled solution, which would probably work in 90+% of the Flash applications out there. For the freaks like us that are relying on a stable timer and LocalConnection we could explicitly say that we want full FPS even when hidden.

The argument that this could be abused is moot in my opinion. This is the current behavior so you are not making something worse even if everyone decides to opt out from throttling. Besides, what would be the motives for people to ‘abuse’ this behavior? Some evil scheme to waste CPU cycles on people’s computers?

But until then?

If you application is running into problems because of the throttling, there are some things you can try to make things better.

1. Loop a silent MP3 in your applications. Yes, I am serious. This will ramp up the FPS from 2 to 8. Still not much, but four times faster.

2. For LocalConnections you can run a separate LocalConnections per client (if applicable). This will allow you to send more data per tick. *

3. Batch data over LocalConnections. Aggregate as much as you can between ticks and then send it as an Array. Pack it up on the other side.

Remember that when your ticks go down you need to try and perform as much work as possible for each tick. Of course, this is a bit against the design principles for an asynchronous framework, but hey, that’s what happens when you start to nerf the framerate.

* Edit: This does not seem to be possible. The routing seems to be executed outside the LocalConnection, meaning that all events sent will be dispatched sequentially in a throttled manner to all recipients. Ergo, if you have one broker and four clients (think online poker game with one lobby and four tables) then for the 2 FPS case each client will receive a maximum of 1 event every two seconds. Yikes.

Fredrik Johansson is a founder and CEO of Cubeia Ltd.

You can contact him at: fredrik.johansson(at)cubeia.com

Firebase Lobby and Bandwidth

Thursday, April 1st, 2010 by fredrik

Upon popular demand I have made an analysis of the bandwidth requirements for running the Cubeia Poker on Firebase with the lobby. The scope was to test 8 000 simulated poker users on a 4-way cluster where every user is also subscribing to the entire lobby tree (i.e. all tables). The values of interest are external and internal bandwidth usages.

This somewhat technical document can be found here.

Problems with Comments + Flash

Wednesday, February 10th, 2010 by larsan

For some reason I can’t seem to comment at the moment. So if you’re experiencing problems, please bear with us.

In the last post, netsql asked about action script support (as upposed to Flex) for Firebase, and I’ll post my answer here for the time being: Good point, it should be documented. As far as I know, but I’m no Flash coder, the API is the same. So you should be able to download it and then use the Flex examples to find your way.

Drop me a line (lars.j.nilsson at cubeia dot com) and I’l let you know when we have something up on the wiki. Otherwise just hang around, we’ll get it updated in the next few days.

Update: Oh, apparently commenting is on again.

Behold the Site!

Friday, February 13th, 2009 by larsan

After a few years of ‘who care about the looks’ mentality, we now have redesigned the entire website. The system is still Joomla, but now the template is ‘HiveMind’ from the excellent RocketTheme.com. Really good stuff!

So… What do you think?