High Memory Usage - Unity profiler shows that a single font texture takes up more than 150 MB of memory on android device - unity3d

While trying to optimize a Unity game I discovered that font textures take up a ridiculous amount of memory on mobile devices (tested on Android - OnePlus 6). The texture does not seem to be cleared between scene switches, unlike the Editor, where the maximum size of a font texture is 4 MB at all times (even in the same scene with loads of different text elements) and does not climb any higher. Meanwhile, opening new scenes/windows with different texts increases the font texture memory even more and more on my phone. The attached image shows the profiler snippet when profiling my OnePlus 6 phone, after navigating to multiple scenes and opening different panels with various texts (which were using the same font).
My question is: what can I do about it - is it a bug or a feature? Why is the allocated texture memory not cleared/reset as it is on the Editor?

Related

Reducing Build size of VR project

I am building a 360 Virtual tour for Samsung GearVR using Unity 5.6.
I want a high resolution image to be seen in the GearVR to get a good experience to the end user so i didn't compress the original photosphere image and also set the resolution to 8192 in import settings in unity.This gives a high resolution and clear picture in GearVR .
But the problem is that the image which I have clicked is just of 5.8 MB and after importing without compression it became 64 MB.
This is adding up to my Application size. Since it is a virtual tour I will have to import many such pictures which is then eventually going to be a huge sized application which is not good.
I tried compressing it in unity import settings but that gives me a low resolution(blurry ) image in GearVR.
Is there any solution through which I can get a high resolution image as well as less app size?
If you want to have great resolution and high user impact in your Unity project, then you have to encounter with high application size.
You can set the same quality options to reduce the file size of your application via;
Edit->Project Settings->Quality
Also, here are some ways for reducing the file size of your build.
Set the Resolution to 8192 and compression quality to high quality and check crunch compression in unity import settings of image to reduce the application size during build.
We will get high resolution image and the application size won't be too large.

Unity Game Crashes on IOS with Message didRecieveMemoryWarnining

I have developed a game in unity. Which works fine on android but when I tested it on IOS my game crashes after playing 3 levels. I have tested it using XCODE 8. Before crashing didRecieveMemeoryWarning() appear and then "game terminated due to memory issue" . I have compressed my all textures. Double checked my code.I did everything that I can think of. Plz guys help me.
Right After building your game, You can see how big your game is and how many space is taking every file included, to see this, right click on the console tab and select "Open Editor Log" as mentioned in this link. If there is some files that are taking too many space, consider reducing its size, with textures/sprites is as easy as setting a max size to a lower value.
If your build is fine in Android it may be that your textures/sprites are not in a size power of 2 (like 128x128, 256x256, 512x512, and so on...). Unity can't compress this images unless they are power of 2 in iOS.
To solve the above problem without having to manually change every texture of your game, I recommend using packing tags in your sprite options, you can assign the same tags to sprites so they create an atlas, see documentation here. Normally you want to pack together sprites that belong to the same level or menu and try avoiding having atlases bigger than 2048x2048, to see your atlases you can go to the Sprite Packer Window.

App crashes in Retina enabled device with low memory warning But in works perfect in non retina devices

I am developing a cocos2d game which is retina enabled . I have added lots of images in my project for both retina and non retina. Game works fine in simulator [Both retina and non retina], and it also works perfect in non retina devices. But when i run the same in the retina enabled device means it get's crashed without displaying any message. When i test my game with instrument application means it shows low memory warning message like this [http://screencast.com/t/sfRDTELrhomC]. When the app get's crash While running in the retina enabled device it's doesn't show any error message in the console. I am terribly confused with the current state can anyone help me out with this problem.
You are probably using a lot of memory to load images, so the device runs out of memory and kills your application.
I'm guessing you are using PNGs (since you didn't give any info on this); when you load an image from PNG, JPG, etc., the image is loaded into memory twice, since it has to be "translated" by cocos into a texture. Also, texture sizes for this operation has to be a power of 2, so an image of 150x150 would take the memory of an image of 256x256. This is a lot of wasted memory.
My first suggestion is to buy Texture Packer (I'm in no way affiliated with them, it's just a great piece of software), which takes your images and makes them into a compressed PVR sprite sheets that contain several images in one texture.
PVR files are loaded directly into a texture, so they don't use double memory, and since they are sprite sheets, you have less wasted pixels.
My second suggestion is to, when loading your images, not do it all in the same tick of the runloop; Cocos uses a lot of autoreleases, and that memory is not cleared until the end of the tick, so instead of loading all images into memory in the same method at once, schedule that method to be called several times and load a new file every time.

iOS 5 - animated gifs showing in wrong colors sometimes

I'm using some animated gifs on our mobile-site. It's a clock-animation and since the iOS 5 update it sometimes happens that the clock gets blue instead of red, as planned. Happens on iPhone4 and iPhone5 with the new os.
Any ideas what could cause the problems? It's hard to reconstruct this failure but it happens from time to time.
Any help would be appreciated.
Sometimes ios devices may not be able to process all the images because of its relatively low graphics ability compared to that of a computer. Instead of using a GIF I would suggest using an animated PNG. This has been more popular among the ios devices as using GIFs has become obsolete when working with ios devices. I am not sure how fast this would be, but I would say it can apply less stress then that of a gif. Another idea, because it is a clock gif is to analyze the gif in a program and determine any problems. Also use imgoptim (for mac) or pngcrush for windows to reduce the size of the gif to reduce the stress on the processor.
use GIF 128 Dither and Please make sure that images size has to be base on the resolution it happen some time if your images size is not depend on retina or normal resolutions. And if I am not wrong you facing problem only in retina device, may be below details will help
iPhone Retina Display
~~~~~~~~~~~~~~~~~~~~~~~
Width - 640px
Height - 960px : including 40px status bar
DPI - 326
You can use Cocos2D framework, Cocos2d and UIKIT both work great with out any graphic related errors... Sprite sheets reduces the memory usage and also support all transparant images , you can run animation ,stop and repeat them. Good luck..

How to handle loading multiple images for the purpose of scrolling and zooming? Does DPI of an image affects the way an iPad is going to load it?

I am currently working on an image gallery for iPad. As of now there are about 100 images and the count may increase further. The images I am using are of the resolution 2134x1602 # 300dpi. Now with ~2.5MB, i have lost the smoothness in scrolling the images to next image. Also I want to zoom the image up to 8X. The images I am using are all PNG type.
The app works fine in the simulator but crashes bad on the device. Instruments show no leaks and no bad allocations too. It must be some Internal memory issue for sure since the gdb reports memory warning while running on the device. I would like to tell you that I am lazily loading the images.
Can anyone help me with this issue and the strategy i should use to get rid of the slow loading and scrolling. Also I'll be glad if you let me know how an iPad's GPU processes the images it wants to load. Also i would like to cite that changing DPI didn't work out well.
Eagerly waiting for some help.
Thank You.
Your app is crashing because you are running out of memory.
What you will need to do is scale/tile the images. Have a look at how Google Maps works in a web browser on a normal PC, you will need to do something like this. The screen resolution on the iPad is 1024x768 pixels, so there's no point loading more than that amount of data at any one time. When displaying your image at > 0.5x scale, tile it into sections that are max 1024x1024, pre-scaled. Cache everything to disk. When displaying your image at < 0.5x scale, consider having thumbnails at different resolutions. In between different resolutions, do an alpha blend of two images of different scales: eg for scale 0.75x, do a 50% blend of four tiled scale 0.5x images and one scale 1.0x image.