Does Apple thinning work on Cocod2d-x?

Can you explain why App Thinning is this important to you? Can you explain your specific use case? I am also taking a read over this.

So by using apple thinning, when we deploy our app universally, people that download the iphone 5 version, will download the assets of the ipad pro as well. Our app it is a picture book, so we have a lot of background images, and it is a big compromise to use that many repetitive background with different ratios. With apple thinning, each device will access/download only the assets that we design for each asset.

I don’t understand why is not very popular or a simpler way to implement it. It seems that the problem may be the pvr.czz assets.

App thinning should be a separate thing from cocos2dx. It’s both an Xcode project settings and possibly, but shouldn’t need to, modify your loading directories/paths.

That’s what I think so. I’d think it is a pretty straight forward operation. But we are having problems loading the pvr images.

I’m trying to know if anybody has managed to do it before and use this feature with cocos2dx projects and pvr.ccz and jpg sets of images.

I can’t think I’m the only one in need of this feature in the whole cocos2dx community. I’m kind of lost here.

Most games that use cocos2dx don’t need more require more than 100MB (w/all archs), but App Thinning should be supported of course.

The obvious (me thinks) questions:
Are you using Asset Catalogs to store app thinning resources?
Have you been successful loading .png from an Asset Catalog in cocos2dx?
Have you been successful loading .jpg from an Asset Catalog in cocos2dx?
Have you been successful loading .pvr from an Asset Catalog in cocos2dx?
Are you trying to support App Slicing? (just curious)
Are you trying to support On-Demand Resources? (just curious)

I’ll prob take a look at this for a bit in a test app since I use Asset Catalogs in “regular” iOS apps, but have yet to try App Thinning (haven’t needed > 100MB yet in non-Unity-built games), but had fun trudging through the .apk expansion pack process a couple years back :frowning: .

@theflyingsquid ahhhh … Is cocos2dx supporting App Thinning feature in iOS 9? … I see it looks more like you haven’t tried yet, so you’re checking before having to learn it all yourself? It looks like someone figured it out over there, at least one method.

We’re just in need for app slicing, because at this point our apps are 180mb but without all the different device assets they could be under 100mb.

Actually we have tried that method on the thread you posted and somehow we can’t make it to work with our app. So I was wondering if my Programer is missing something or that method is not working anymore.

I’m an independent artist, making this project at this point out of passion and a programmer is helping me out.

Just wanted to confirm if is possible to do it. I don’t expect people to write the code for me, just guide me in the right direction. I wish I could know about programming but the only code I know is “If” “else” and “then”. I don’t think I can go very far with that. :slight_smile:

Thanks Steve for your response.

Hi Ivan. To my knowledge, cocos2d-x does not support Assets catalog (and so, the App thinning process won’t do much). You could, however, do a little programming to support it on iOS only: instead of loading images with the Sprite::create method, use [NSImage imageNamed: …]. That will search on the assets catalog and return the image. Then you will need to create a Sprite from that NSImage. Code will look like this:

	// search imageKey in assets catalog
	auto image = [UIImage imageNamed:@(imageKey)];

	// convert NSImage to Texture
	NSData* data = UIImagePNGRepresentation(image);
	auto length = [data length];
	unsigned char* buffer = (unsigned char*)malloc(length);
	[data getBytes:buffer length:length];
	auto img = new Image();
	img->initWithImageData(buffer, length);
	auto tex = new Texture2D();
	tex->initWithImage(img);

	// create sprite		
	auto sprite = Sprite::createWithTexture(tex);

	// free buffers
	tex->autorelease();
	free(buffer);

I have also used assets catalogs with JPGs. For that, you need to set the Render As option to Original Image (in Xcode select the Image set and change the RenderAs option on the panel on the right). Haven’t tried with PVR, but I guess the same procedure should work too.

btw, the app thinning process is something done by the AppStore (it provides different “slices” of the app depending on the device is requesting it). cocos2d-x could provide support for reading images from assets catalogs, but Android builds will still be “downloaded in full” since there is no thinning process on other stores (Google, Amazon, …) as far as I know.

Hope that helps!

1 Like

@kmaker, thanks for the info!

Another option would be to store the excess data on your own server (or Amazon S3, for example). The use the asset manifest and downloader classes. This is what many of the free to play games do.

While it would require user to download more data you could have the baseline resolution assets in the main install and then optionally download the higher-res art afterward and just have your code choose the higher one if available/exists and fallback to the regular assets bundled with the game’s .ipa/.apk

Thank you so much for for the help.

We’re going to try it out and see if that guides us to a successful apple thinning! :slight_smile:

I really appreciate it.

Also thank you very much for the time and your ideas.

My programer suggested this a few days ago. One of the issues with this approach is that our app is a children’s app for young children, and there are pretty strict regulations to comply when developing this kind of apps. I’m not sure if using this kind of technology complies with Coppa. I’ll do some research on that. But thanks anyway, it is good to know that at least that way definitively works.

Hello Everyone,
I have a little different problem… i dont want app thining or app slicing. I want to know about On Demand Resources. I am also developing children based app. We dont have different asset sets for different devices but have lots of mini games. What i want is if user or kid clicks on icon that mini game should get downloaded on Demand. Please Refer this link if i am not clear.

https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/AppThinning/AppThinning.html#//apple_ref/doc/uid/TP40012582-CH35-SW3

So do i have to do it natively on xcode side or i can do it through cocos2d-x or is there some easy way.

try assetmanager or downloader features in cocos2dx

I know asset Manager a little but what is downloader…

Hello,
Asset Manager works Fine, but what i want is Initial Install tags. Which comes with ios 9 and later.

My Client mailed me these links.

https://forums.developer.apple.com/thread/73640

https://www.reddit.com/r/iOSProgramming/comments/5y6gil/apple_starts_rejecting_apps_with_hot_code_push/

He is having a valid point. What he wants is initial install tags. I searched on youtube but i didnt got any good video or reference. What i was getting was either swift or spriteKit examples but nothing on side of C++ or cocos2d-x.

Please just point me in the right direction. I want Initial install tags working, Apple app thining feature.

Hello Jugnu,

In our case, regarding App thinning, we used assets manager, but the problem we encountered was that I think in order to have apple Thinning work, we need to activate “Bite Code Enable” inside the bundle settings, and we can’t make bite code enable work with Cocos2d-x.

So we basically gave up trying to make Apple Thinning work on Cocos2d-x. It kind of sucks, because it is quite important for us.

That link you post is interesting. Thanks for sharing.

If you manage to make apple thinning work. (I know it’s not your intention anyway) but if you find out how to make it work, please points in the right direction.

Thanks.

Why are you saying you cannot enable bitcode in cocos2d-x?

I’m just the designer, not the programmer, so I may be wrong. But my understanding was that, my programmer could enable bitcode for cocos2dx but then it would make our app a complete mess and pretty much unusable. We are using spine animations with a combinations of pngs, jpegs, and pvr.czz.

We pretty much gave up on apple thinning. we can’t make it to work with our assets. I saw another post that somebody was claiming it worked, but I am still not sure apple thinning is possible with cocos2dx or at least with the type of assets we are using.

If somebody managed to make it work with spine animations / pvr.czz / jpegs and pngs, I wouldn’t mind paying some cash for the help, guidance. But at this point, we pretty gave up on apple thinning and we compromised packing all the assets in same build.

  • Cocos works with design resolution concept; a design res is chosen, and is then adapted to any screen with open gl tricks (viewport magnification).
    Apple has multiple resolution categories, that is, you design for every app device res (with some reusability) and you ship the app. Based on that, apple the applies slicing.
  • Same for resources: sprites require to be 1@,2@ etc in the apple sprite folder; so you have to duplicate cocos ones :frowning:
  • Ditto for on-demand resources… need to tag them, but after all the above… they are bundles… (not sure on this)
  • You can only skip on bitcode: you just need to recompile EVERY part/library of cocos with bitcode enabled. So you just need to know where the secret files are… :wink: your programmer knows.

So app thinning this way is a lot of work, almost unpredictable, directly against your choice of using cocos; because if you are using cocos it’s because it’s multi platform. So you probably be ending up managing all those resources externally anyway yourself (with firebase, or now-dead parse) server things…
As you see, multi platform philosophy breaks app thinning…