Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Game Crashes on Android when activating TextMeshProUGUI

Discussion in 'Android' started by VINNUSAURUS, Oct 3, 2022.

  1. VINNUSAURUS

    VINNUSAURUS

    Joined:
    Jul 6, 2017
    Posts:
    18
    Code (CSharp):
    1. Debug.Log("1");
    2.         string opponentCardValue = packet.ReadInt().ToString();
    3.         //this object contains a Image component and a TextMeshProUGUI as child, crashes when activated
    4.         UIManager.uiManager.PlayerCard.SetActive(true);
    5.  
    6.         yield return new WaitForEndOfFrame();

    Code (CSharp):
    1. Error Unity Graphics device is null.
    2. Error Unity TMPro.TextMeshProUGUI:Awake()
    3. Error Unity <OpponentGuessedDefeat>d__27:MoveNext()
    4. Error Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
    5. Error Unity HomeToGame:HandleData(Byte[])
    6. Error Unity HomeToGame:DataReceived(Object, DataReceivedEventArgs)
    7. Error Unity SuperSimpleTcp.<<DataReceiver>b__72_0>d:MoveNext()
    8. Error Unity System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start(TStateMachine&)
    9. Error Unity SuperSimpleTcp.SimpleTcpClient:<DataReceiver>b__72_0(Task`1)
    10. Error Unity System.Threading.Tasks.ContinuationResultTaskFromResultTask`2:InnerInvoke()
    11. Error Unity System.Threading.Tasks.Task:Execute()
    12. Error Unity System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
    13. Error Unity System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
    14. Error Unity System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&)
    15. Error Unity System.Threading.Tasks.Task:ExecuteEntry(Boolean)
    16. Error Unity System.Threading.ThreadPoolWorkQueue:Dispatch()
    17. Error Unity
    18. Error Unity [ line -1286672140]
    19. Error Unity
    20. 0001-01-01 00:00:00.000 -1 -1 Info  --------- beginning of crash
    21. Fatal libc Fatal signal 5 (SIGTRAP), code -6 (SI_TKILL) in tid 11767 (IL2CPP Threadpo), pid 11618 (ompany.Guessed)
    22.  
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,507
    You'd be better posting on the dedicated TextMeshPro forum here.

    Want me to move your post?
     
    VINNUSAURUS likes this.
  3. VINNUSAURUS

    VINNUSAURUS

    Joined:
    Jul 6, 2017
    Posts:
    18
    Please move it thanks you for help
     
  4. shelim

    shelim

    Joined:
    Aug 26, 2017
    Posts:
    28
    The error message is cryptic, but I believe there is reason behind that. It is a wild guessing, but it may still help someone

    1. You start your SuperSimpleTcp. It actually spawns a new thread under the hood for the new connection
    2. You call Log method from that thread. This is okay - so far.
    3. You have a custom log handler that attempts to "print" the just written log in form of TMPro prefab. This is not allowed (we are not in the player thread now!) and crashes.

    It may be even 2 and 3 connected -> you are attempting to create TMPro prefab outside of player thread.

    Surprisingly there is no crash in-editor for the same scenario.

    The solution would be to output TMPro prefab in main thread (for example log handler might enqueue things to write on main thread)
     
  5. audry

    audry

    Joined:
    Feb 15, 2018
    Posts:
    4
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,507
    Could you see that I was moderating the post only?