Jeremy LaCivita

hack

Rich Media Hacker

Illustrations

USFSA Kayak theSlalom Cookies Free Skate BattleUS

Sketch

jawa mooch squash monkey chainsaw claws dragon hand2 head spread hand spidey hand marvin hand closed

Interactive

Carcassone Game Funky Valentine

Archive for the ‘hack’ Category

Race Conditions in Flex VideoDisplay

Nov 14, 2007

The Flex mx.controls.VideoDisplay object is a double edged sword. If you’ve used it for anything complex, you’ve likely noticed that it gets very finicky under certain conditions. Thats really a shame, since it provides many useful features, like rtmp vs http connection management, bandwidth detection, and various optimizations to connection speeds to name a few.

On the Fan, we’ve occasionally had problems with playing lists of videos with VideoDisplay, and we’ve had to jump through a few hoops in order to continue to use it so that we’d still get all its benefits. The problem generally consists of the VideoDisplay getting into a state where it stops responding to subsequent calls to load() & play().

We had worked around most of these by moving around our code to avoid apparent race conditions in VideoDisplay, and we even had to monkey-patch the VideoDisplay & VideoPlayer classes to get around a problem were it would load the netstream twice for the same video and you’d get a double/echoing audio stream. While working with one of our partners recently, we came up against another bug in VideoDisplay that we couldn’t get around. This time it was throwing an error like this:

ArgumentError: Error #2126: NetConnection object must be connected.
  at flash.net::NetStream/construct()at flash.net::NetStream()
  at VideoPlayerNetStream()[E:\dev\flex_201_borneo\sdk\frameworks\mx\controls\videoClasses\VideoPlayer.as:2883]
  at mx.controls.videoClasses::VideoPlayer/createStream()[E:\dev\flex_201_borneo\sdk\frameworks\mx\controls\videoClasses\VideoPlayer.as:2712]
  at mx.controls.videoClasses::VideoPlayer/_load()[E:\dev\flex_201_borneo\sdk\frameworks\mx\controls\videoClasses\VideoPlayer.as:2170]
  at mx.controls.videoClasses::VideoPlayer/load()[E:\dev\flex_201_borneo\sdk\frameworks\mx\controls\videoClasses\VideoPlayer.as:1486]
  at mx.controls::VideoDisplay/load()[E:\dev\flex_201_borneo\sdk\frameworks\mx\controls\VideoDisplay.as:1361]

It actually involves not only VideoDisplay but also VideoPlayer (which VideoDisplay has an instance of) and even NCManager (which does some of the stuff mentioned above). My counterpart at the other company wasn’t seeing this error in his test environment, but eventually we realized what the crucial difference was: autoplay was set to false in the Fan, while it was left to its default (true) in his test player.

Since he had it working with no problem, i decided to see what would happen if i left autoplay at its default value of true.

Well, there were some side effects related to videos playing before i was ready for them, however the broken state of VideoDisplay went away! Now I simply pause the VideoDisplay right after i set the source to simulate having autoplay set to false. This has the added benefit of buffering the movie right away instead of later on, so i’m pretty happy with the solution (although i think VideoDisplay should do that anyway if it was written properly)

Update: here’s the code we used to patch mx.controls.videoClasses.VideoPlayer:

public function ncConnected():void {
  if (_ncMgr == null || _ncMgr.netConnection == null)
    setState(CONNECTION_ERROR);
  else{
    if (!alreadyLoaded) {
      alreadyLoaded = true;
      createStream();
      setUpStream();
    }
  }
}

Obviously we also added a variable declaration for alreadyLoaded, and we also reset it to false in the _load function (you can’t miss it, there’s a ton of variables getting reset in the function)

Update: here’s a screenshot of my project structure showing how to “underride” the adobe class.mx_packages.png 

tags

Posted in The Fan, flex, hack

13 Comments »

Milestones: Team and Individual

Aug 24, 2007

Well, we launched the Fan 4.0 with an extremely low amount of friction. Other than M$ gimping Adobe’s Flash auto updater code in Vista, there weren’t any problems. We pushed a quick HTML only fix, and within 24 hours, Adobe had fixed their installer anyway (well, they did the same thing we did and put up a message saying Vista sucks)
(more…)

tags

Posted in Comcast, The Fan, hack

No Comments »

Fruit of my labor - Fan 4

Aug 3, 2007

We just uploaded the latest Fan 4 Beta to the preview servers. I’ve spent lots of hours implementing the design, so check it out and tell me what you think!

(Be sure to check out “Square” view, as thats were most of the changes are)

tags

Posted in Comcast, The Fan, flex, hack

5 Comments »

At Comcast for a month

Jul 29, 2007

Well, its been about a month since I started working at Comcast Interactive Media. The first thing i’ve noticed is that there is a distinction between Comcast and CIM. The culture at CIM is not at all like your typical workplace, and thats a good thing.

Working on the Fan is really fun and interesting. I’m getting to learn Flex and also work on a very high profile consumer entertainment app at the same time. I can’t wait until we release the latest version to the public. Until then, you can check out our regular preview releases at CIM|Labs

tags

Posted in Comcast, The Fan

No Comments »

Hello world!

Jul 28, 2007

This is my first post. Well thats not actually true. Its the default post that wordpress puts into a new installation. I’ve changed the text here to make it my own though. I’ve also imported all my old skating posts from theSlalom.com. I need to find a way to keep this blog and that one in sync.

tags

Posted in hack, teach

2 Comments »