OpenFL running slow on the Apple TV

Oh, I forgot, since Next is written in Haxe, you can look at the profiler stacks to see where time is spent in the rendering calls:

Perhaps not surprisingly, it’s all in SpriteBatch.renderTiles. (Of course, it doesn’t show you what’s inlined.) I wonder if it would be interesting to run it with --no-inline (is that a valid switch?)

Thanks for the analysis @jeff_ward. I tried to compile the same example with the --no-inline switch and there’s some more info for you to have a look at: https://dl.dropboxusercontent.com/u/3098924/bunnymark-next-tilesheet-version-tvos-no-inline.hxt.zip

What is needed to compile for tvOS? When I try it I get this error:

Do I need to install lime from github?

I don’t know if hxcpp and lime have been released since my patches went in. If you want to give it a try you can set haxelib to use my repo for both lime and hxcpp (remember to use the tvos branches):


On top of that you also need to clone my version of SDL (tvos branch again) and replace the src/ and include/ folders in lime/project/lib/sdl
https://bitbucket.org/santinelli/sdl/src/3f20f7ff3cbfceb948fe293113cdf0a14d11126e?at=tvos

I’m still waiting for the guys at SDL to merge my tvOS changes into the main repo. And Lime is using the sdl-native project that is set to a specific revision of the SDL repo so you have to do a bit of copy & paste to get everything ready to deploy on the Apple TV.

Thanks - this is what I get.

I installed everything per your instructions.

Then, once I try to compile something, I get "This version of hxcpp (/usr/lib/haxe/lib/hxcpp/git/) appears to be a source/developement version.
Before this can be used, you need to:

  1. Rebuild the main command-line tool, this can be done with:
    cd tools/hxcpp
    haxe compile.hxml
  2. Build the binaries appropriate to your system(s), this can be done with:
    cd project
    neko build.n
    "

Once I do that I get an error message: Error: In file included from ./lib/sdl/src/SDL_hints.c:21:
In file included from ./lib/sdl/src/./SDL_internal.h:34:
lib/sdl/include/SDL_config.h:52:2: error: Wrong SDL_config.h, check your include path?
#error Wrong SDL_config.h, check your include path?

And then if I try to compile after that, I’ll get this error: Error: Source path “/usr/lib/haxe/lib/hxcpp/git/lib/AppleTV/libstd.appletvos-64.a” does not exist

So should I have generated the libs before copy/past your SDL mods?

I think this could be helpful to other developers willing to play around with tvOS.
I’m going to go over this with you just like if I had to do it from scratch.

I’m assuming you have Haxe 3.2.0 installed on a Mac. I’m still on Yosemite so I do not know if El Capitan could bring issues to my workflow.

First thing we get hxcpp running:

git clone https://github.com/tanis2000/hxcpp.git
cd hxcpp
git checkout tvos
cd ..
haxelib dev hxcpp hxcpp
cd hxcpp/tools/run
haxe compile.hxml
cd ../build
haxe compile.hxml
cd ../hxcpp
haxe compile.hxml
cd ../../project
neko build.n
cd ../..

Next up is our copy of SDL and Lime

hg clone https://[email protected]/santinelli/sdl
cd sdl
hg update tvos
cd ..
git clone https://github.com/tanis2000/lime.git
haxelib dev lime lime
cd lime
git checkout tvos
git submodule init
git submodule update --recursive
cd project/lib/sdl/include
mv configs ../
cd ..
rm -rf include
rm -rf src
cp -R ../../../../sdl/include ./
cp -R ../../../../sdl/src ./
mv configs include/
rm include/SDL_config.h
lime rebuild tools -v -clean
lime rebuild tvos -v -clean

At this point you should be able to go to your project folder and do an openfl update tvos -v -clean to get the XCode project for tvOS.

Let me know if that works for you or if you encounter any problem.

Cheers!

1 Like

Thanks so much for that, unfortunately it does not seem to be working just yet.

First,

haxe compile.hxml
cd …/project <<<< Should be two levels up, I think

neko build.n
cd …/…

But more importantly, when I try to build the tools, this is what I get:

lime rebuild tools -v -clean

Error in building thread
g++ -Ilib/sdl/include/ -Ilib/sdl/include/configs/mac/ -DHAVE_LIBC -DUSING_GENERATED_CONFIG_H -DTARGET_API_MAC_CARBON -DTARGET_API_MAC_OSX -D_THREAD_SAFE -mmmx -msse -msse2 -c -fvisibility=hidden -stdlib=libstdc++ -O2 “-I/Users/hak88/Documents/workspace/test/hxcpp/include” -DHX_MACOS -m64 -Wno-parentheses -Wno-unused-value -Wno-format-extra-args -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=0 -x c ./lib/sdl/src/SDL_error.c "-o/Users/hak88/Documents/workspace/test/hxcpp/project/lime/project/obj/darwin64/d1952bb7_SDL_error.o"
Error: In file included from ./lib/sdl/src/SDL_error.c:21:
In file included from ./lib/sdl/src/./SDL_internal.h:34:
lib/sdl/include/SDL_config.h:52:2: error: Wrong SDL_config.h, check your include path?
#error Wrong SDL_config.h, check your include path?
^
1 error generated.

So this is the exact same error I had before. Any idea how to fix this?

Well, I don’t know much about the in’s and out’s of rendering, but here’s normal (with inlining):

And here’s what’s revealed without, aka --no-inline:

So the time is mostly being spent in fillVertices, with significant time from there also in ArrayBufferIO.set calls - not sure if that’s helpful, obvious. or otherwise. :smile:

I know why it’s failing. I made you replace the whole project/lib/sdl/include.
You should actually first move the project/lib/sdl/include/configs somewhere safe.
Then you can remove the old include folder and replace it with the one from my SDL repo.
Next copy the configs back there.
And finally remove the include/SDL_config.h

This should solve your issue.

Let me know if it works. Cheers!

1 Like

Getting real close.

I think what needs to be added to your script is this in the end:

lime rebuild hxcpp tvos

else, you do not have the libs in hxcpp you need.

After that, compile seems possible, however I can’t really tell yet, as I’m searching for the right cable right now to connect to my appleTV.

It seems, compiling to the simulator is not possible so far, build fails, while compiling to a binary with openfl fails on the certificate step. Xcode does not want to compile for me without the TV connected, So I’ll get a cable now and will report back

Actually the line neko build.n should build all of the hxcpp targets, including the tvos one. It’s wrong that you have to rebuild it again after messing around with Lime.

It looks like I forgot something somewhere along the toolchain to get the simulator working. I tried as well and it seems that it’s not passing the correct architecture and SDK path down the pipe. I’ll look into it.

And yeah, you need a developer certificate to deploy on the device, just like you do for iOS.

Strange, I did not have the TVOS libs in hxcpp (only in lime).

But, more importantly I got it running on my appleTV.

Yeah! Thanks so much.

No I need to figure out how get a Mouse pointer. Will Mouse events work in general or do I need to the Joystick class?

That’s good to hear! :smile:

AFAIK mouse clicks are being passed down the pipe when the user clicks on the remote (only the click on the touch area and the play button are mapped right now).
I don’t know about the mouse position as I’ve not checked it out. So far I’ve been using the GamePad class to deal with the remote.

Do you have an example for the GamePad class? The API has changed so much that none of the examples I find seem to work

This is how I use it:

Thanks for the link - does not work for me at all, no idea why. Gamepad never registers anything. Similar to what this guy reports:
Gamepad-Api not working

That’s because Lime is still using an old version of SDL: https://github.com/native-toolkit/sdl/commits/master

You’ve got to wait until they upgrade to the latest SDL version or you’ve got to upgrade SDL yourself. You can find info about how I usually do it right on this same thread: OpenFL running slow on the Apple TV

Has support been merged into the main SDL tree now?

Hold on- but I build SDL according to your instructions from your repo - else my app would not be running on twos at all, no?

Further info - I’m running your hxcpp + lime gits and openfl 3.3.8. Using 3.3.9 introduces strange display problems.

Not yet.
My suggestion is to wait as it will be merged soon. The Apple TV launch is just around the corner.