Search Unity

the PlayerLoop internal function has been called recursively.

Discussion in 'Web' started by goyadb, May 16, 2022.

  1. goyadb

    goyadb

    Joined:
    Mar 11, 2016
    Posts:
    8
    Hello,
    When I press button many time, showing error.
    I think problem is JSON.stringify(), How can I fix it?

    Error
    Build.framework.js:1766 An abnormal situation has occurred: the PlayerLoop internal function has been called recursively. Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it.

    My source code

    GameManager.cs
    Code (CSharp):
    1. public class GameManager : MonoBehaviour
    2. {
    3.     [SerializeField] TextMeshProUGUI resultText;
    4.  
    5.     [DllImport("__Internal")]
    6.     private static extern string testFunc();
    7.  
    8.     public void OnClickGetButton()
    9.     {
    10.         string resultStr = testFunc();
    11.     }
    12. }
    *.jslib
    Code (JavaScript):
    1. mergeInto(LibraryManager.library, {
    2.     testFunc : function() {
    3.         var obj = {
    4.             name: "Bryan",
    5.             age: 33
    6.         };
    7.         var result = JSON.stringify(obj);
    8.         var bufferSize = lengthBytesUTF8(result) + 1;
    9.         var buffer = _malloc(result);
    10.         stringToUTF8(result, buffer, bufferSize);
    11.     }
    12. });
     

    Attached Files:

    • a.PNG
      a.PNG
      File size:
      411.4 KB
      Views:
      310
    • b.PNG
      b.PNG
      File size:
      357.6 KB
      Views:
      301
  2. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    273
    The issue you have here is a memory access out of bounds issue, due to this line:
    Code (JavaScript):
    1.  var buffer = _malloc(result);
    You should be mallocing the bufferSize instead:
    Code (JavaScript):
    1.  var buffer = _malloc(bufferSize);
     
  3. NetworkingServices

    NetworkingServices

    Joined:
    Mar 28, 2022
    Posts:
    20
    Hello, I'm receiving an error: "An abnormal situation has occurred: the PlayerLoop internal function has been called recursively. Please contact Customer Support with a sample project so that we can reproduce the problem and troubleshoot it." . I've literally tried just about everything but it doesn't seem to be working.

    I'm using an auth for my game, so when you load you need to register an account, this way your stats save... however if I run it in Unity, I can function it 100%, however when I build/run (both local and on my site: https://networkingsgamelounge.xyz) I am unable to login at all... whenever I press "login" it just stops basically.

    I tried to remove the auth login page to see if the game would work without it... and it does, but I'm still getting that error so I think maybe that error is causing the auth not to work properly or? ... if anyone could assist me, I'd greatly appreciated it, thanks.
     
  4. juiceAw

    juiceAw

    Joined:
    Jun 29, 2018
    Posts:
    1
    in my case:
    i have a Dictionary object
    Code (CSharp):
    1. Dictionary<string, List<Sprite>> m_AniDict = null;
    when i call Dictionary.TryGetValue() method
    Code (CSharp):
    1. if (m_AniDict.TryGetValue(name, out m_CurAniList))
    2. {
    3.  
    4. }
    if the Dictionary is null , will report this error
     
  5. mickfcna

    mickfcna

    Joined:
    May 13, 2019
    Posts:
    46
    Hello,

    I have the same issue. Any fix ?
     
  6. krishnasawlani

    krishnasawlani

    Joined:
    Jan 12, 2017
    Posts:
    1
    Hi,

    I'm also having the same issue

    I'm sharing my code below:-

    MainPanel.cs
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using TMPro;
    6.  
    7. using UnityEngine.SceneManagement;
    8.  
    9. public class MainPanel : MonoBehaviour
    10. {
    11.  
    12.  
    13.     public GameObject ConnectingPanel;
    14.     public TMP_InputField nameInput;
    15.     public TextMeshProUGUI welcomeTest;
    16.  
    17.     // Start is called before the first frame update
    18.     void Start()
    19.     {
    20.         welcomeTest.text = "Welcome " + PlayerPrefs.GetString("DisplayName");
    21.         ConnectingPanel.SetActive(false);
    22.        
    23.     }
    24.  
    25.     // Update is called once per frame
    26.     void Update()
    27.     {
    28.        
    29.     }
    30.  
    31.     public void NeonCity()
    32.     {
    33.         ConnectingPanel.SetActive(true);
    34.         SceneManager.LoadScene(4);      
    35.             Time.timeScale = 1;
    36.     }
    37.     public void VKing()
    38.     {
    39.         ConnectingPanel.SetActive(true);
    40.         SceneManager.LoadScene(5);
    41.             Time.timeScale = 1;
    42.     }
    43.     public void MarketPlace()
    44.     {
    45.         ConnectingPanel.SetActive(true);
    46.         SceneManager.LoadScene(6);
    47.             Time.timeScale = 1;
    48.     }
    49.     public void SwitchScene()
    50.     {
    51.         //ConnectingPanel.SetActive(true);
    52.         SceneManager.LoadScene(2);
    53.             Time.timeScale = 1;
    54.     }
    55.    
    56.  
    57.     public void Login()
    58.     {
    59.         //ConnectingPanel.SetActive(true);
    60.  
    61.          PlayerPrefs.SetString("DisplayName", nameInput.text);
    62.        SceneManager.LoadScene(1);
    63.             Time.timeScale = 1;
    64.     }
    65.  
    66.  
    67.  
    68. }
    69.  


    CharacterSelection.cs
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class CharacterSelection : MonoBehaviour
    7. {
    8.  
    9.     public GameObject[] characters;
    10.     public int selectedCharacter = 0;
    11.     public GameObject connecting;
    12.  
    13.     void Awake ()
    14.     {
    15.         connecting.SetActive(false);
    16.         characters[selectedCharacter].SetActive(true);
    17.     }
    18.  
    19.     public void NextCharacter()
    20.     {
    21.         characters[selectedCharacter].SetActive(false);
    22.         selectedCharacter = (selectedCharacter + 1) % characters.Length;
    23.         characters[selectedCharacter].SetActive(true);
    24.     }
    25.  
    26.     public void PreviousCharacter()
    27.     {
    28.         characters[selectedCharacter].SetActive(false);
    29.         selectedCharacter--;
    30.         if (selectedCharacter < 0)
    31.         {
    32.             selectedCharacter += characters.Length;
    33.         }
    34.         characters[selectedCharacter].SetActive(true);
    35.     }
    36.  
    37.     public void StartGame()
    38.     {
    39.         connecting.SetActive(true);
    40.         PlayerPrefs.SetInt("selectedCharacter", selectedCharacter);
    41.         SceneManager.LoadScene(3, LoadSceneMode.Single);
    42.     }
    43. }
    44.  


    LoadCharacter.cs
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using TMPro;
    5.  
    6. public class LoadCharacter : MonoBehaviour
    7. {
    8.     public GameObject[] characterPrefabs;
    9.     public Transform spawnPoint;
    10.     public TMP_Text leable;
    11.     public GameObject ScenePanel;
    12.  
    13.     void Start()
    14.    
    15.     {
    16.         ScenePanel.SetActive(false);
    17.         Time.timeScale = 1;
    18.  
    19.        
    20.         int selectedCharacter = PlayerPrefs.GetInt("selectedCharacter");
    21.         GameObject prefab = characterPrefabs[selectedCharacter];
    22.         GameObject clone = Instantiate(prefab, spawnPoint.position, Quaternion.identity);
    23.             Cursor.visible = false;
    24.             Cursor.lockState = CursorLockMode.Locked;
    25.            
    26.     }
    27.  
    28.     private void Update() {
    29.         {
    30.            
    31.         if (Input.GetKeyDown(KeyCode.Escape))
    32.         {
    33.            
    34.            ScenePanel.SetActive(true);
    35.            Time.timeScale = 0;
    36.            Cursor.lockState = CursorLockMode.None;
    37.             Cursor.visible = true;
    38.         }
    39.         }
    40.     }
    41.  
    42.     public void DisablePanel()
    43.     {
    44.         ScenePanel.SetActive(false);
    45.         Time.timeScale = 1;
    46.         Cursor.lockState = CursorLockMode.Locked;
    47.         Cursor.visible = false;
    48.     }
    49.  
    50.  
    51. }
    52.