Friday, October 9, 2009

I had a project to design a Flash component API that needs to be easy to integrate with all video players. I had investigated more than a dozen video players used by web publishers of any size. These video players included big brand names like YouTube and Brightcove, and generic players such as JW and Flowplayers. The goal is simple: the Flash component API needs to work on any given web pages. Making jobs easy for other developers means we have to do all dirty works.

Some web sites have lots of problems in their HTML markups and JavaScripts. Often times, these publishers have no engineering resource to maintain their code. They probably did not test their site performance across different browsers on different platforms. Some bad codes are not fatal but just make the site slow. But for anyone who needs to add code into it, watch out!

More than once, I found my Flash component failed to load on IE. It's always perfect on Firefox. It also happened only on a few sites.

It turned out that this was a timing issue caused by some JavaScripts that IE had problems with. When I initialized my Flash components, the Flash stage size was ZERO! Yes, you don't always get the stage dimension you set in HTML object tag. Solution? I now always add a timer to poll stage width and height till both are not zero before I even initialize any objects in ActionScript. This is a protection for my ActionScript because I have no idea how it will be used by others.

Remember, if your Flash does not work on IE, and IE only, always check if Flash stage size is zero! Before you can fix your JavaScripts and make IE happy, you can always protect your ActionScripts by waiting till Flash stage is properly initialized.

Sunday, September 27, 2009

The following is an ad request chart of my iPhone app, Men vs Chimps Lite, for the first three weeks since its first release. Do you find anything interesting? Notice that today, 9/27/2009, is a Sunday.

Although the data is limited, I found that Wednesday, Thursday and Friday usually have peak usages. I have thought people may use iPhone apps more often on weekends. Obviously, I was dead wrong! From the chart, Saturday has the lightest app usages.

Perhaps, people are having fun on the weekend and they don't need iPhone apps. Everyone works hard on Monday and Tuesday. By Wednesday, iPhone users are already looking for weekends and use (entertainment) apps to kill time.

Saturday, September 19, 2009

I spent quite some time Friday morning trying to figure out a weird problem. The problem was not there when executing code in command line in a production machine or in a local environment.

It turned out that I made a mistake that I had never known. I had a function looks like

def a(m=[]):
m.append(1)
return m

If you call a() three times, you get

[1]
[1 1]
[1 1 1]

which was not what I expected. I used m as a flag to select algorithms, and the function a() was called exactly once in every process. In a single thread process, everything seems ok. But in a multi-threading environment, once a flag is set, the flag will be there for all subsequent calls.

I checked Python documents and found that "the default value is evaluated only once." That's a potential problem if you use list or dict as a default argument in Python. It essentially says that a list or a dict as default is taken as a static object. If the argument is read-only, you are fine. If you want to overwrite the argument, make sure you intend to use the list or dict as a static object. For me, I rewrote my function like

Facebook 3.0 for iPhone was available in Apple App Store late night August 27th. People were so excited as you could see the wave at Twitter. I found a bug that crashed the app every time I scrolled my friend list to the bottom (friends' names in Chinese) and reported it to Facebook. Then Facebook 3.0.1 came out three days later. Bugs fixed. That was really QUICK! Yesterday afternoon, September 3rd, Facebook 3.0.2 was out. That was unbelievably efficient from Apple.

Set aside any discussion to remove iPhone app review process for now. As a small developer, I have another concern about a level playing field in the app review process. I was very surprised it took Apple only 11 days to review Facebook 3.0. It took Apple two weeks or more to review my app for its first release and also a subsequent update. My app, Real-Time Stocks, has only five views (aka screens), obviously cannot compare with Facebook for its breadth of functionality. How could Apple approve a huge Facebook app a few days faster than my tiny app? What's more shocking to me, Facebook 3.0.1 and 3.0.2 were both approved in about three days. That really disturbed me.

I submitted a new app, Men vs Chimps, on August 25th, and just received ready-for-sale notice from Apple yesterday evening. Now I know during the review process for my app, Apple approved three Facebook app submissions. My little iPhone app has only three views: a menu, a game view, and a result view. You don't even have to count to know Facebook app has more than ten times as many views as mine. But the most important point here is that Facebook submitted two updates a few days after my submission, and both of them came out ahead of mine.

Now, I want to know if Apple is willing to update my app on a super fast track if I have a bug fix for my app. Didn't I pay as much as Facebook did for the standard iPhone Developer Program? As long as there is a review process for iPhone apps, I suppose all apps should play by the same rules. Unless there is a rule that I don't know.

It has been a long time since last update. I have removed posts that were meant to be experiments for old work. They are in the past. From now on, I will write more of my thoughts and many useful programming tricks, libraries, and tools that I have used in various projects.

I still write C/C++ and actually used it alone to develop all the computer vision and image/video processing algorithms for an internet video object tracking project for my current company. However, I will say that the most fun in programming is probably in Python, ActionScript 2/3, JavaScript, and Objective-C/iPhone. Lots of fun comes from programming with APIs like YouTube, Facebook, and many others. Expect I write more on these stuff.