I just ran into a very unfortunate problem with the AOT compiler, and I thought I better share this with the Starling community. It's quite a bummer for my Starling 2.0 plans, unfortunately. 🙁
I had implemented a new part of Starling 2.0, and it ran fine on my Mac and on Android. But on iOS, the performance was really terrible.
It took me a quite while to find the root of the issue. It turned out to be interfaces!
Let's say you've got the following class, implementing an interface:
class Runner implements IRunner
private var _miles:uint = 0;
public function run(count:int):void
for (var i:int=0; i<count; ++i)
Now you create two references, using either the "Runner" class or the "IRunner" interface for the object type:
Let both references point to the exact same object:
runner = new Runner();
iRunner = runner;
When I call the "run" method on both references, you'd expect about the same performance for both calls, right? You are calling the same method on the same object, after all.
With the JIT-compiler, the performance is indeed roughly identical.
But with the AOT compiler, it will suddenly be massively slower! Calling the method on the interface reference takes about 25 times as long as calling it on the object reference; and that's with a long loop in the method. The difference would be even more severe with, say, a simple getter.
If there is no workaround (or fix) for this issue, interfaces are a complete no-go on iOS, at least for anything performance critical. Bye-bye, "IRenderer" interface! I'm not sure yet how I can adapt my new architecture to this severe limitation ... 😢
Except anyone has seen this and knows of a workaround?
Thanks a lot in advance for any help!