IOS device troubleshooting
For iOS, in some cases, the game can run perfectly in the Unity editor, but it cannot run or even start on the actual device. These problems are usually caused by code or content quality. This section describes the most common situations.
After the game stops responding for a period of time, the Xcode status bar displays "interrupt )".
There are many reasons for this phenomenon, including:
Script errors, such as using uninitialized variables.
Use third-party Thumb to compile the local library. This library triggers known issues in the iOS SDK connector and may cause random crashes.
Use a generic type with a value type as the parameter (for example, List <int>, List <SomeStruct>, List <SomeEnum>, and so on) for serialization.
Use reflection when managed code striping is enabled.
An error occurred while using the local plug-in Interface (the method signature of the hosted Code does not match the function signature of the local code ).
The XCode debugging Console information helps you detect such faults (Xcode menu: View> Debug Area> Activate Console )).
The Xcode console displays "Program received ed signal:" SIGBUS "or EXC_BAD_ACCESS error.
This message usually appears on the iOS device when the application receives the NullReferenceException. There are two ways to locate the location where an error occurs:
Managed stack tracing:
From version 3.4 onwards, Unity contains software-based null references (NullReferenceException) for processing. The AOT compiler allows you to quickly view all empty references every time you access a method or variable of an object. This feature affects script performance, which is why this feature is only enabled in development and building (in the basic edition license, you can Build Setting) the "development build" option is displayed in the dialog box. However, you must enable the "script debugging" option for the iOS professional license ). If the above content is correct, the error actually appears.. NET code, you will no longer see EXC_BAD_ACCESS ,.. NET exception text will be displayed on the Xcode Console (or the code will be processed in the "catch" Statement ). The typical output may be:
Unhandled Exception: System. NullReferenceException: A null value was found where an object instance was required.
At DayController + $ handleTimeOfDay $121 + $. MoveNext () [0x0035a] in DayController. js: 122
This indicates that the error occurs in the handleTimeOfDay method of the DayController class and is a coprocessor. In addition, if it is a script code, it will prompt the row number of the error (for example, "DayController. js: 122 "). The statement may be as follows:
Instantiate (_ imgwww. assetBundle. mainAsset );
This error may occur if the script accesses the resource package without checking whether the download is correct.
Local stack trace:
Local stack tracking is a more powerful tool for fault investigation, but using it requires some professional technology. Generally, this type of Local Machine (Hardware Memory Access) fails and cannot continue. To trace the local stack, enter bt all in the Xcode debugging console. Check the displayed stack trace carefully, which may contain error source information. You may see the following information:
...
Thread 1 (thread 11523 ):
#0 0x006267d0 in m_OptionsMenu_Start ()
#1 0x002e4160 in wrapper_runtime_invoke_object_runtime_invoke_void _ this ___ object_intptr_intptr_intptr ()
#2 0x00a1dd64 in mono_jit_runtime_invoke (method = 0x18b63bc, obj = 0x5d10cb0, params = 0x0, exc = 0x2fffdd34) at/Users/mantasp/work/unity-mono/External/Mono/mono/mini. c: 4487
#3 0x0088481c in MonoBehaviour: InvokeMethodOrCoroutineChecked ()
...
First, we should find the stack trace of "Thread 1", which is the main Thread. The first line of the stack trace points to the location where an error occurs. In this example, the trace shows that NullReferenceException occurs in the "Start" method in the "OptionsMenu" script. Check the implementation of this method to find out the cause of the fault. Obviously, NullReferenceExceptions occurs in the Start method and incorrect assumptions are made on the initialization sequence. In some cases, the debugging console only shows a small part of the stack trace:
Thread 1 (thread 11523 ):
#0 0x0062564c in start ()
This indicates that the local symbols have been removed during the application release. To obtain complete stack trace information, follow these steps:
Delete an application from a device.
Clear all targets.
Build and run.
Obtain the stack trace information as described above again.
When the external library is linked to the Unity iOS application, EXC_BAD_ACCESS starts to occur.
This usually occurs when the external library is compiled by the ARM Thumb instruction set. Currently, this library is not compatible with Unity. You can easily solve this problem without using the Thumb command to re-compile the database. To re-compile the Xcode project of the library, follow these steps:
In Xcode, choose "View"> "Navigators"> "Show Project Navigator" from the menu )"
Select the "Unity-iPhone" project and activate the "Build Settings" tab.
Enter "Other C Flags" in the search field"
Add the-mno-thumb flag here and re-build the database.
If the source of the database is unavailable, contact the provider to obtain the non-thumb version of the database.
The Xcode console displays "WARNING-> applicationDidReceiveMemoryWarning ()", and the application crashes.
(Sometimes you will see information such as Program passed ed signal .) This warning usually does not cause the program to crash completely. It only prompts that the IOS device has insufficient memory and requires more memory space to be released. In general, background processes such as Mail can release some memory space so that the application can continue to run. However, if the application continues to use memory or requires more, the operating system will eventually kill the application, which may include your program. Apple does not prompt the minimum memory size required. However, experience shows that if there is no less than 50% mb ram space (for example, 2nd generations of ipad ~ 200-256 MB memory. The primary measure is how much RAM space the application occupies. The application's RAM space is mainly composed of four parts:
Application code (the OS needs to load and save the application code in RAM, but some code will be discarded if necessary)
Local Memory (the engine uses local memory to save its status and resources to RAM)
Managed memory (used for Mono running time, saving C # or JavaScript objects)
Memory Pool of gles driver: texture, frame cache, and compiled coloring device.
Application memory usage can be tracked using three Xcode tools: Activity Monitor, Object Allocations, and VM Tracker ). You can start from Xcode running menu: Product> Profile and select a specific tool. The Activity Monitor tool displays statistics of all processes, including the actual memory, which can be viewed as the total amount of RAM used by applications. Note: The combination of OS and device HW versions may significantly affect the memory usage. Therefore, be cautious when comparing the quantity obtained by different devices.
Note: the internal analyzer only displays the memory allocated by the. NET script. The total memory usage can be determined by using Xcode, as shown in. This number includes the binary values of some applications, some standard framework buffers, the internal state buffers of the Unity engine, and ,. NET runtime memory (values are displayed by the internal analyzer), GLES driver memory, and other miscellaneous.
This tutorial article is organized and recommended by the unity3d tutorial of the game manniu