Question: tvOS support

Plain SDL is working fine. So it’s definitely not a problem with SDL itself.

I tried with a very simple example that should display a bitmap and a filled rectangle (shape):

It still shows a black screen. I’m pretty sure the problem isn’t SDL .What could I do to debug what’s being fed to SDL from OpenFL?

BTW I tried the Lime examples.

  • HelloWorld works like a charm.
  • SimpleImage fails with Error Null Object Reference and it’s because image.buffer is null. Trying to trace image.data throws the same error.

So the first step is probably to find out why Lime is actually creating an Image object but it’s not loading the bitmap.

I debugged a bit more and the problem is in this function in Lime:

File: ExternalInterface.cpp

value lime_image_load (value data) {
	
	ImageBuffer buffer;
	Resource resource;
	
	if (val_is_string (data)) {
		
		resource = Resource (val_string (data));
		
	} else {
		
		Bytes bytes (data);
		resource = Resource (&bytes);
		
	}

The resource = Resource (val_string (data)); line is returning a Resource object with a NULL data property.

If I understand correctly that Resource object is only a data structure and data is NULL because the asset is actually just a string that is assigned to the path property.

Then the heavy lifting is done by the PNG::Decode function.

In PNG::Decode, the file = lime::fopen (resource->path, "rb"); returns NULL in file and then returns, so the image is not being read.

The path of the file is assets/lime.png while I’d have expected it to be the full path to the resource in the application bundle. Any clues?

More progress on this. Lime is fine. OpenFL seems to be fine (codewise).
The problem is that the image isn’t located in the correct path. for some reason, at compile time, it gets copied in `assets/assets/lime.png".
If I move it back by one folder it works fine. Who’s telling where to copy those files?

I’m slowly getting there. I fixed the path for Lime and now it works correctly.

Now it’s only OpenFL that isn’t displaying anything other than a black screen. When I load the bitmap, it’s actually there and I see that it’s not null. Tracing the height and width it shows that it’s 512x200 so that’s fine. But when it’s added to the Sprite, it just doesn’t show anything.

The same happens when drawing directly on the screen with primitives.
Any idea what else I might be missing?

It’s party time! :smile:
Got it running on tvOS!!

@singmajesty you’ve got some stuff from me:

Eventually, I wouldn’t mind being able to work on the official repo of Lime and its submodules as it’s a real pain to keep track of changes without forking all of the submodules and changing the references in my fork of Lime.
I can’t even switch between my iMac and MacBook without patching all this stuff by hand.
Cheers! Please let me know if you need anything to pull all this stuff in the official repos.

I’ve looked through the HXCPP pull request, it looks good to me, but I want to give Hugh a chance to take a look before pulling :smile:

The Lime changes looked good, I made a couple changes, I removed the additional “assets/” prefix in the getImage function. I believe that appending the paths later on in DefaultAssetLibrary.hx (similar to iOS) should already handle this

I pulled the changes for the Lime submodules, but I had to remain on our current SDL commit for the meantime. This should minimize manual changes on your end to the official Lime release, but a tweaked SDL submodule. We want to stay on main-line SDL as much as we can, perhaps you could try talking to @icculus on Twitter? He’s a core contributor and has been helpful before :smile:

The OpenFL changes look good, they’re pulled

Onward and upward!

SDL changes are a must if we want to offer tvOS as a target. I’ll get in touch with @icculus.
I’ve already merged my changes to their default repository. I only need to find how to send a pull request over :smiley:

Are you sure about removing the “assets/” prefix? If you do so, any project using plain Lime won’t be able to read the correct assets. AKA the Lime examples will fail loading bitmaps.

As far as I understand, the default project uses “Assets”, renamed to “assets”, so “openfl.png” should be at “assets/openfl.png” when publishing.

The iOS project template puts all assets (of any name) under an “assets” folder, so “assets/openfl.png” is located at “assets/assets/openfl.png”

DefaultAssetLibrary prefixes all the path values with “assets/” on the iOS target (and now the tvOS target), so an asset of “assets/openfl.png” should result in a path of “assets/assets/openfl.png” and resolve to the correct file, right? :slight_smile:

It should :smile:

I will test it with plain Lime anyway just to make sure though :wink:

While we wait for @icculus to tell me something, here’s the latest SDL (from their repo) with my tvOS changes merged in and tested: https://dl.dropboxusercontent.com/u/3098924/openfl/sdl-submodule-latest.zip

Have you tested iOS yet? Do you see any of the issues I saw?

You’re right. It looks like the bitmap is being stretched in a weird way. But it doesn’t happen with plain SDL as I just checked it out moments ago. It’s definitely something we’re doing in Lime/OpenFL.
I can’t understand with the SimpleImage project of Lime if it’s doing the same as that texture does not fill the whole screen and I have no clue how to make it fill the screen :smile:

You can either change the data array to use window.width/window.height instead of image.width and image.height, or change the matrix to be image.width/image.height instead of window.width/window.height, and I think that should stretch the image across the whole screen, though it might be hard to tell if it was retina then :slight_smile:

Hi,
Did any news about tvOS support?
What all now?

As far as I can tell, everything is right there in the latest develop branch of the projects involved. I’m pretty sure that you would need to create the static libraries of the current version of hxcpp by hand as they’re not being distributed at the time I’m writing this.

This won’t be an issue in future versions of hxcpp as the build system has changed and those static libraries will no longer be needed.

Hi,
Thanks for help.
In total to start build for tvOS I need download and install:
-dev version of lime from https://github.com/openfl/lime/tree/develop
-dev version of openfl from https://github.com/openfl/openfl/tree/develop
-dev version of hxcpp from https://github.com/HaxeFoundation/hxcpp/tree/master
Than, run console command lime rebuild tvos
Right?

Right now that won’t be enough. you’d also need to rebuild the tvOS static libraries of hxcpp before you can build your project for that platform

Ok, and can you provide command for rebuild tvOS static libraries of hxcpp?
Did I must use last version of openfl or can stay on last stable and can I use legacy version of openfl?
Thanks again

You have to go into hxcpp’s folder and type the following:

cd project
neko build.n tvos

You have to use the “next” version as legacy isn’t supported for that build platform.

I’ve been trying to get everything to build for AppleTV as well and I have run the following commands:

haxelib git openfl https://github.com/openfl/openfl
haxelib git lime https://github.com/openfl/lime
haxelib git hxcpp https://github.com/HaxeFoundation/hxcpp
lime rebuild tvos

Unfortunately things fail while attempting to compile SDL. I believe the SDL version that lime includes is using some now-removed APIs for audio:

Error: While running :xcrun --sdk appletvos9.2 clang++ -Ilib/sdl/include/ -Ilib/sdl/include/configs/default/ -DHAVE_LIBC -D__IPHONEOS__ -D__TVOS__ -fobjc-arc -c -stdlib=libc++ -O2 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk -mappletvos-version-min=9.0 -fobjc-arc -DOBJC_ARC -Wno-parentheses -Wno-null-dereference -Wno-unused-value -Wno-bool-conversion -fno-stack-protector -DAPPLETV=APPLETV -DAPPLETVOS=APPLETVOS -fembed-bitcode -DENABLE_BITCODE=YES -DSTATIC_LINK -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=0 -I/usr/local/haxe/lib/hxcpp/git/include -fexceptions -fstrict-aliasing -x c ./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c -o/usr/local/haxe/lib/lime/git/project/obj/appletvos-c11-64/b3e8e549_SDL_coreaudio.o
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:682:5: error: implicit declaration of function 'AudioSessionInitialize' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    AudioSessionInitialize(NULL, NULL, NULL, nil);
    ^
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:682:5: note: did you mean 'AudioUnitInitialize'?
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/System/Library/Frameworks/AudioUnit.framework/Headers/AUComponent.h:1139:1: note: 'AudioUnitInitialize' declared here
AudioUnitInitialize(                            AudioUnit                               inUnit)                                         
^
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:683:23: error: use of undeclared identifier 'kAudioSessionCategory_AmbientSound'
    UInt32 category = kAudioSessionCategory_AmbientSound;
                      ^
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:684:5: error: implicit declaration of function 'AudioSessionSetProperty' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(UInt32), &category);
    ^
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:684:5: note: did you mean 'AudioServicesSetProperty'?
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioServices.h:310:1: note: 'AudioServicesSetProperty' declared here
AudioServicesSetProperty(   AudioServicesPropertyID             inPropertyID,
^
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:684:29: error: use of undeclared identifier 'kAudioSessionProperty_AudioCategory'
    AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(UInt32), &category);
                            ^

I’m not really awesome enough with Haxe and all that to know what to do here. I assume somehow there are likely changes in the upstream SDL that need to be merged into Lime’s SDL or something like that?