Issues Switching to Android in Unity - android

I have developed an Augmented Relity app for iOS in Unity. It has a good performance.
The app has several scenes but one of them is much much larger than the others (about 60 targets).
The app size in iOS (uncompressed) is massive (1.9Gb) becouse it has a lot of media (images, videos, textures and 3D content).
Now I'm switching the platform to Android and I'm having a lot of trouble:
-The loading time to the principal scene is very very high (10 or more minutes) rather than 20 seconds in iOS (iPhone 4).
-The textures of the 3D content turns in black.
Is there a limitation size for a scene in Android?

Maximum memory available on android might differ per device.
Most only have 256 MB of memory available for a single application.
As for texture memory (again different per device), you might want to look at the compression used. Using the android standard ETC Unity page on Android should improve loading times. Removing Mip Maps would lower memory use and loading but also potentially decrease FPS (depending on wethere they are used or not).
With Android there is also the option to profile through ADB connection within the Unity Profiler, which could help with narrowing down to a more exact cause of the problem.

Related

Is there a limit for TextureAtlas size?

I am new in game development and want to develop a phone game. I am trying to make a complex animation in libgdx, which consists of nearly 300 images (655 × 1160 each, together in size of 42MB). Is there a limit in how big textureAtlas image can be or how many pictures it takes? Will there be a problem if I render 7 animations at once, while 2 of them are as complex as this one (activated skill), but others are just simple character movements?
The atlas can be as big as you have RAM for. The more RAM you have, the bigger atlases you can load.
On Android, you may have problems loading 42 MB big images as it's a lot of allocation at once. There have been multiple posts on Stack Overflow about just that problem. You just have to try loading it and see what happens. If the game crashes with an OutOfMemoryException, you have to make it smaller.
Because Android is a platform with a lot of variation in hardware (some devices have 512 MB total ram while others have 6 GB) there's no "hard limit" to what you can load in on a platform basis. It depends on what device and how much RAM is available (free RAM)Disclaimer: this answer is old and doesn't represent a realistic RAM distribution anymore. With certain phones having as much as 16 gigs of RAM and most flagships boasting at least 4 GB, 42 MB shouldn't (realistically) be a problem anymore. Android RAM allocation is still one of the weirdest systems in existence, and sufficiently large bitmaps may throw an exception separately. Bitmaps in this case do mean through the Bitmap class in "regular" android, and not directly OpenGL and/or LibGDX.
What the TextureAtlas actually contains (complex animations of 30 images vs 2 massive images) doesn't matter. As long as you load it (and manage to get it into memory without the game crashing) there's not going to be a problem rendering it. The framerate may drop though (depending on hardware and how much you actually render) but unless you render thousands of images at once it shouldn't be a problem
Adding android:largeHeap="true" in the manifest is also helpful.

Android AIR application developed in Flash CS6 did not run smoothly on mobile phone

I have developed AIR application for Android in Flash CS6.
But the problem is, the application doesn't run smoothly on mobile phone.
I can't find the solution to my problem. Is it because of too many scenes or too many key frames in a scene?
Thank you so much for the explanation.
at first, take a look at this
when you find issues with only phones, it means that device is not enough strong to execute and render your app as fast as you want:
i know following points strongly change your performance in phone devices
using complex vectors, and trying to update them each frame (scale
is most harmful case)
high definition screen resolution of device (in this case you must avoid full-screen if necessary)
using CPU as render target, it must be changed to GPU (not even
direct)
a 24-30 fps would be best because you have more chance to play and
create everything with same speed as runtime fps
memory management and garbage collection
using bitmap objects instead vector graphics, you can keep storing
vectors in your app for advantage of reducing disk size, but its
possible to rasterizing them in runtime and letting CPU breathing
easily

Starling for IOS & Android: Very low FPS in a static situation

I created an application with Starling, on the new mobile devices it performs amazingly well, however on the older devices (e.g. iPhone 4) I encounter a very odd lag.
I have as far as I can tell a completely static situation:
There are quite a few display objects added to stage, many of them are buttons in case it matters, their properties are not changed at all after initialization (x, y, rotation, etc...).
There are no enterframes / timeouts / intervals / requests of any kind in the background.
I'm not allocating / deallocating any memory.
In this situation, there's an average of 10 FPS out of 30, which is very odd.
Since Starling is a well established framework, I imagine it's me who's doing something wrong / not understanding something / not aware of something.
Any idea what might be causing it?
Has anyone else experienced this sort of problem?
Edit:
After reading a little I've made great optimizations in every possible way according to this thread:
http://wiki.starling-framework.org/manual/performance_optimization
I reduced the draw calls from around 90 to 12, flattened sprites and set blendmode to none in specific cases to ease on CPU, and so on...
To my surprise when I tested again, the FPS was unaffected:
fps: 6 / 60
mem: 19
drw: 12
Is it even possible to get normal fps with Starling on mobile? What am I missing?
I am using big textures that are scaled down to the size of the device, is it possible that such a thing affects the fps that much?
Regarding "Load textures from files/URLs", I'm downloading different piles of assets for different situations, therefore I assumed compiling each pile into a SWF would be way faster than sending a separate request for each file. The problem is, for that I can only use embed, which apparently uses twice the memory. Do you have any solution in mind to enjoy the best of both worlds?
Instead of downloading 'over-the-wire' your assets and manually caching them for re-use, you can embed the assets into your app bundle vs. embedding them and then use the Starling AssetManager to load the textures at the resolution/scale that you need for the device:
ie.
assets.enqueue(
appDir.resolvePath("audio"),
appDir.resolvePath(formatString("fonts/{0}x", scaleFactor)),
appDir.resolvePath(formatString("textures/{0}x", scaleFactor))
);
Ref: https://github.com/Gamua/Starling-Framework/blob/master/samples/scaffold_mobile/src/Scaffold_Mobile.as
Your application bundle gets bigger of course, but you do not take the 2x ram hit of using 'embed'.
Misc perf ideas from my comment:
Testing FPS with "Release" mode correct?
Are you using textures that are scaled down to match the resolution of the device before loading them?
Are you mixing BLEND modes that are causing additional draw calls?
Ref: The Performance Optimization is great reading to optimize your usage of Starling.
Starling is not a miracle solution for mobile device. There's quite a lot of code running in the background in order to make the GPU display anything. You the coder has to make sure the amount of draw call is kept to a minimum. The weaker the device and the less draw call you should force. It's not rare to see people using Starling and not pay any attention to their draw calls.
The size of graphics used is only relevant for the GPU upload time and not that much for the GPU display time. So of course all relevant texture need to be uploaded prior to displaying any scenes. You simply cannot try to upload any new texture while any given scene is playing. Even a small texture uploading will cause idling.
Displaying everything using Starling is not always a smart choice. In render mode the GPU gets a lot of power but the CPU still has some remaining. You can reduce the amount of GPU uploading and GPU charge by simply displaying static UI elements using the classic display list (which is where the Staling framework design is failing). Starling was originally made to make it very difficult to use both display system together that's one of the downsides of using this framework. Most professional I know including myself don't use Starling for that reason.
Your system must be flexible and you should embed your assets for mobile and not use any external swf as much as possible and be able to switch to another system for the web. If you expect to use one system of asset for mobile/desktop/web version of your app you are setting yourself up for failure. Embedding on mobile is critical for memory management as the AIR platform internally manages the cache of those embedded assets. Thx to that when creating new instances of those assets the memory consumption stays under control, if you don't embed then you are on your own.
Regarding overall performance a very weak Android device will probably never be able to go passed 10 fps when using Starling or any Stage3D framework because of the amount of code those framework need to run (draw calls) in the background. On weak device that amount of code is already enough to completely overload the CPU. On the other hand on weak device you can still get a good performance and user experience by using GPU mode instead of render mode (so no Stage3D) and displaying mostly raster graphic.
IN RESPONSE TO YOUR EDIT:
12 draw calls is very good (90 was pretty high).
That you still get low FPS on some device is not that surprising. Especially low end Android device will always have low FPS in render mode with Stage3D framework because of the amount of code that those framework have to run to render one frame. Now the size of the texture you are using should not affect the FPS that much (that's the point of Stage3D). It would help with the GPU uploading time if you reduce the size of those graphics.
Now optimization is the key and optimizing on low end device with low FPS is the best way to go since whatever you do will have great effect on better device as well. Start by running tests and only displaying static graphics with no or very little code on your part just to see how far the Stage3D framework can go on its own on those weak device without losing any FPS and then optimize from there. The amount of object displayed on screen + the amount of draw calls is what affects FPS with those Stage3D framework so keep a count of those and always seek ways to reduce it. On some low end device it's not practical to try to keep a 60fps so try to switch to 30 and adjust your rendering accordingly.

Unity3D frame rate dropped after importing Blender model

I am making a 3D game with Unity for Android. In the game there is a main character and up to around 10 opponents possibly on the screen at the same time, all using the same model (prefabs for "opponents" differ only in one material for other colors).
The model was designed using MakeHuman and Blender.
On PC (since rendering is a lot faster) there are no problems, but when testing it on an Android device, the rendering time drops the frame rate to around 25-30 FPS when there are 3-4 or more bodies on the screen, creating a really "laggy" feeling (I am expecting a frame rate of about 60 FPS).
Before importing the Blender model I used placeholder spheres and there was no such behavior. Since this is the first time I am using Blender and such 3D models, I am not sure whether my model is within the expected sizes for a mobile game. My current model consists of: 5,956 Verts, 10,456 Faces, 10,819 Tris with a file size of around 6.5 MB (it was generated even larger by MakeHuman at first, but I managed to compress it and optimize it significantly, but still without major effects).
I attempted different solutions, including merging all meshes in the model into one, turning off shadows, using as least materials as possible, etc. All attempts were with no or very limited improvement.
Any ideas are welcome. Cheers!
My current model consists of: 5,956 Verts, 10,456 Faces, 10,819 Tris
with a file size of around 6.5 MB
Sounds like way too much to me.
Also, keep in mind that if you're doing anything such collision calculations, every extra complexity takes exponentially more time
for a mobile game I would suggest you to remesh the model (even though its not a nice work, but the results are much better than the decimate-modifyer for example) an than bake normalmaps for it from the high-res model.

How can I improve loading speed / publishing speed for an AIR for Android App with many classes?

I have the following scenario:
An app for Android devices that has a few hundred classes. I am using Flash CS5.5, developing in AS3 using AIR for Android.
The app is a puzzle game and each class represents one of the elements from the puzzle. Each class is a derivative of a base class and only holds a few specific information like unique name, category, place in puzzle. Each class also has attached an 80 x 80 px image to it. However, there's about 300 classes like this.
The application runs very smoothly ONCE IT LOADS because it takes forever for the application to publish and then for it to run on the mobile device. I have no issue with the exporting/publishing time being high and the installation time on the mobile device being quite high. But each time I run the application from the mobile device, it takes some 2 minutes for it to load which is abnormally high, not even high-end 3d FPS games load for that long. Tests are done on a HTC Sensation running Android 4.0 and, subsequently 4.1.
My question is, what can I do to help reduce this initial startup time? I mention again, the app runs smoothly once loaded since it is really not that complex nor does it use a lot of graphics aside the many 80x80 JPG images attached to each class. In early testing, when I had like 20-30 classes only implemented, everything was smooth. When I added all the elements needed for the game after the game's logic was complete, everything was slow to load.
Thank you for any answers/suggestions.
If you want to speed up compile times for an AS3 project in Flash CS5.5, go into the Actionscript 3 settings for your .fla and turn off 'Warnings mode'. Warnings mode has a bit of overhead because it tries to give you helpful warnings when migrating code from AS2 to AS3. If you know what you're doing, you can turn this off and save lots of time.
1) File > Publish Settings.
2) Click the wrench icon next to 'Actionscript 3.0'
3) Uncheck 'Warnings Mode'
This cut doing compile times on a big project for me quite a bit. Another thing that helps is to divide up your assets into smaller swfs/swcs that are just brought in during runtime.
Only a partial answer, I'm not sure how to fix up a slow load time on an Android device. Good luck!

Categories

Resources