I've written a Unity3D game and installed on Android. The game often, but not always, crashes during an operation to load a collection of image resources used by my game. Specifically the application disappears into the background and when I select it, it then restarts. At the moment I can't figure out what is causing this behaviour, I've examined logcat logs when this happens but I can't find any message telling what has happened.
Has anyone experienced similar behaviour and if so what was the solution? Is there a way of finding out why the game has crashed or increase memory allocated to it in case the game is running out of memory loading the images?
The size of images and the compression rate are configurable in the Unity IDE, and can change between platforms. In Unity 5, as a default the max size for an image is 2048 or 4096, which are not fully supported in all devices. I suggest as a first solution to go to the Unity project, select the image assets, scroll down to the setting box for each image, click on the Android tab, check the box marked "override for Android", and change the max size to 1024.
Apply the change, play test to confirm the image is still sharp enough, and re-build the game. I believe this may help you solve the issue.
Related
I have a bug plaguing my project that I can't find any resources to online. There are 2 scenes in my app, Menu and Game. Menu has this behavior 100% of the time, whereas Game only loads with this glitch occasionally. It appears that once it happens once in Game, it will happen multiple times consecutively, and then eventually fix itself. Here is the image of what I am seeing: Menu scene --- Game scene
There are no scripts on my Canvas that are not standard Unity scripts, everything is stock. I have also checked the logcat log via command prompt and no errors are thrown.
If you have any information as to why this glitch is happening, please let me know. I think it has something to do with Canvas settings or a missing dependency/package conflict, but no settings that I changed caused the glitch to go away. Thank you for the assistance!
Change UI Scale mode of canvas to scale with screen size instead of constant pixel size
Answered my own question.
If you are making an AR app and have UI in the app, you NEED a regular Unity Camera in the scene alongside your AR Camera. The AR Camera should be tagged 'Main'.
For some reason, UI cannot attach to AR cameras, and while I don't understand why, the solution still works.
I'm working on an app that shows the floor plan of a trade fair. This is a high resolution (3500x4600), but fairly low file size (400kb) PNG image. I have a little component that allows to pan / zoom it.
Now it all works just fine on iOS, but on Android I just cannot get it to work. If I just try to load it in the normal RN (0.56) Image component I get a blank screen. I'm testing on an HTC One M8, which is not exactly brand new, but also not super low end (2 GB Ram). Funnily enough, if I convert it to a 2,6 MB jpg with the same dimensions, it will show up, though the quality is so bad, you cannot read any of the labels.
There are some mostly older github issues on this (like here and here), but none of those solutions (android:largeHeap="true") work for me.
I tried using react-native-svg, but it has the same problem (I guess it eventually gets rasterized?).
I also tried using react-native-fast-image, which uses Glide under the hood instead of Facebook's Fresco, but (you guessed it), it also doesn't work. If I just load the image, it will get downsampled (worse than the jpg). I tried to get Glide to stop doing that (using override), but then I get a blank screen again.
I found this library, which I guess does exactly what I want, but I'd have to wrap it for RN use... which would be quite a bit of work.
Anyone have an idea?
I have had problem with target images using EasyAR. I am developing my app on Unity. All ImageTarget's work fine and all target images are correctly recognized by the app when I run it on Unity. However, when I deploy the app to my Android phone, 2 of my target images can't get recognized. I have a total of 4 images in this app to be recognized: 2 photos of people, which work fine on PC and Android, and 2 pictures with white background, which work fine on PC but not on Android. You can see the not working images here.
I have tried resizing and inverting colors for those images, but it did not work. I also tried to set the ImageTarget to use a different image (a picture of myself, in this case) and it worked fine, which means the problem is not in the configuration of the ImageTarget.
So, my question is, do you know if there is any restriction for target images that would explain why my images are working on PC but not on Android? If not, can you guys help me figure out what is wrong with my app? I have been stuck in this problem for a long time!
Thank you very much.
The images are "difficult to detect" maybe (Reco difficulty) so I think, for make things easier you can add some frame around or line at bottom at the image. The reason of difference between could be the quarlity of cameras and/or speed of processor.
Also see Best practice for adding new target image
I've been playing around with Xcode and Unity for a while, and have made an app in Xcode which has a scrolling background. I want to basically re-create the app in Unity 2d, using the same set of images (if possible). I've imported all of the iPad sized images that I used in Xcode, but have noticed that the quality is a lot poorer when I build using Unity remote.
The image I'm most bothered about is the background, which is a repeating texture that scrolls across the screen. Do I have to mess around with the settings in Unity to get a better image quality? I'm using PNG. Surely the image can't be too small and therefore stretching because I'm using iPad sized images and running the app on Samsung Galaxy S6. Thanks in advance.
Unity Remote stream screenshots to your device, so the quality is not the final.
Maybe you can try to change the settings of UnityRemote.
See
http://docs.unity3d.com/es/current/Manual/UnityRemote4.html
More info/same question:
http://answers.unity3d.com/questions/408896/android-image-quality-is-poor-compared-to-the-qual.html
Find you image in Project tab and select it, then you should see something like this in inspector, experiment with values until you get results you are happy with.
I'm working on a game for android that is near completion, but within the last week suddenly the loading of Bitmap assets used in the game are throwing memory errors.
The main Bitmap in particular that it's throwing errors on is 237kb and 1792X1024 (32 bit). It is a sprite sheet for a player which is why it is so large, the strange thing is it used to load in and I can actually load in a image that's the map of the game that is 400X800 32bit file that's 413KB without any problems (that isn't a typo, the smaller resolution/same bit file appears larger. I'm not completely sure why but I'm assuming it has something to do with the colors involved or the fact the sprite sheet is predominantly transparent). All images were created in GIMP.
I'm unsure what started the errors as there was no change to anything in the code except for an update of the android API (though it would randomly give errors before in early testing). I have also tried loading in only this spritesheet by itself in a new project which it throws errors, but not on the other larger file.
To make things even more strange, I have a backed up APK from a test phone from when the game didn't throw errors that I've even tried decoding out the png spritesheet and using this exact image (and it still throws errors). The only way for it to not throw errors is to increase the VM max heap to above 24MB (the default, the smallest I've tried is 48MB and this worked but it's loading a lot slower than it used to).
Is this a possible manifest problem or did something in the SDK change that I'm not aware of? I've been trying to solve this for several days trying different methods I've found on numerous boards including setting the sample size with Bitmap.options, manifest adjustments, changing it on resize, System.gc(), recycle(), etc.
Does anyone have any idea what could be going on here?
I doubt your actual in-memory bitmap is really 237KB. I'm guessing you have a PNG that's 237KB, but the decoded bitmap is much larger in memory. PNG uses a form of lossless compression. As to why it worked before but not now I'm not sure, but I'm not in the least surprised that you're running out of memory with bitmaps that big.
You can use a tool to compact/generate your sprite sheet. Something like this might be useful:
http://spritesheetpacker.codeplex.com/
If you are getting an OutOfMemory error then I had the same problem and fixed it as follows. I truly think it is a bug in the native Bitmap code.
Here is what I did: Don't use BitmapFactory.decodeStream or BitmapFactory.decodeFile. Instead use BitmapFactory.decodeFileDescriptor
If that works for you, please let me know as it will help confirm if there is really a bug in the other methods.