RecursiveFrog 发表于 2022-11-10 13:07

unity2022 webgl 加载资源出错 exception thrown: TypeError ...

老项目unity 2019升级到2022,项目中的错误
an abnonal sitution has occuret: th Playercop ifntenal funtion ha be called recursvly,Please contactlutorer Sipport with a saple pvoject so that ve cn rearouce theproblem and troubleshoot it.
UnityEngine.Networking.UnitywebRequest:BeginlebRequest()UnityEngine.Networking.UnitywebRequest:SendlebRequest()woogilorld.AssetBundles.ABLoadFileAsync :.ctor(String)
woogiWorld.AssetBundles.ABManager:LoadAssetBundleInternal(String,Boolean)WoogiWorld.AssetBundles.ABManager:LoadAssetBundle(String,Boolean)
woogilorld.AssetBundles.ABManager:Initialize(String)
woogivlorld.AssetBundles.ABManager : Initialize()
不知道为何,在知乎的照片特模糊,我保证 我上传的是高清图片。


模拟测试
public class Test3 : MonoBehaviour
{
    public string url ="https://*****/StreamingAssets/AssetBundle/WebGL/WebGL.webgl";
    public UnityWebRequestAsyncOperation webRequest;

    IEnumerator Start()
    {
      Debug.Log("Init Start:" + url);
      yield return new WaitForSeconds(5);
      webRequest =
            UnityWebRequestAssetBundle.GetAssetBundle(url).SendWebRequest();
      yield return 0;
      while (!webRequest.isDone)
      {
            yield return 0;
      }

      Debug.Log("Init Completed! " + webRequest.webRequest.downloadedBytes);
    }
}

exception thrown: TypeError: Cannot set properties of undefined (setting '1'),TypeError: Cannot set properties of undefined (setting '1')
    at _JS_WebRequest_Create (blob:http://127.0.0.1/d05375fb-4c26-4487-b2f5-4da97ff15bf5:3:75110)
    at wasm://wasm/0e8982b2:wasm-function:0x329bda1
    at wasm://wasm/0e8982b2:wasm-function:0x329b062
    at wasm://wasm/0e8982b2:wasm-function:0x329ab6f
    at wasm://wasm/0e8982b2:wasm-function:0xfd6ecb
    at wasm://wasm/0e8982b2:wasm-function:0x329b38d
    at wasm://wasm/0e8982b2:wasm-function:0x30d4b28
    at wasm://wasm/0e8982b2:wasm-function:0xd50a8e
    at invoke_ii (blob:http://127.0.0.1/d05375fb-4c26-4487-b2f5-4da97ff15bf5:3:417257)
    at wasm://wasm/0e8982b2:wasm-function:0x2337219
    at wasm://wasm/0e8982b2:wasm-function:0x307f1a9
    at invoke_iii (blob:http://127.0.0.1/d05375fb-4c26-4487-b2f5-4da97ff15bf5:3:415239)
    at wasm://wasm/0e8982b2:wasm-function:0x2337074
    at wasm://wasm/0e8982b2:wasm-function:0x307f1a9
    at invoke_iii (blob:http://127.0.0.1/d05375fb-4c26-4487-b2f5-4da97ff15bf5:3:415239)
    at wasm://wasm/0e8982b2:wasm-function:0x18049ef
    at wasm://wasm/0e8982b2:wasm-function:0x946fb
    at wasm://wasm/0e8982b2:wasm-function:0x307f19d
    at invoke_iiii (blob:http://127.0.0.1/d05375fb-4c26-4487-b2f5-4da97ff15bf5:3:415917)
    at wasm://wasm/0e8982b2:wasm-function:0x214db2e
    at wasm://wasm/0e8982b2:wasm-function:0x1689c3
    at wasm://wasm/0e8982b2:wasm-function:0x288bbb
    at wasm://wasm/0e8982b2:wasm-function:0x307f19d
    at invoke_iiii (blob:http://127.0.0.1/d05375fb-4c26-4487-b2f5-4da97ff15bf5:3:415917)
    at wasm://wasm/0e8982b2:wasm-function:0xb2f28
    at wasm://wasm/0e8982b2:wasm-function:0x1037671
    at wasm://wasm/0e8982b2:wasm-function:0x8a889
    at wasm://wasm/0e8982b2:wasm-function:0x35b0da
    at wasm://wasm/0e8982b2:wasm-function:0xe99633
    at wasm://wasm/0e8982b2:wasm-function:0x320b7f2
    at wasm://wasm/0e8982b2:wasm-function:0xe9bd39
    at wasm://wasm/0e8982b2:wasm-function:0x1129b56
    at wasm://wasm/0e8982b2:wasm-function:0x1129bc7
    at wasm://wasm/0e8982b2:wasm-function:0x34ce53
    at wasm://wasm/0e8982b2:wasm-function:0x307f054
    at browserIterationFunc (blob:http://127.0.0.1/d05375fb-4c26-4487-b2f5-4da97ff15bf5:3:240659)
    at callUserCallback (blob:http://127.0.0.1/d05375fb-4c26-4487-b2f5-4da97ff15bf5:3:193857)
    at Object.runIter (blob:http://127.0.0.1/d05375fb-4c26-4487-b2f5-4da97ff15bf5:3:195117)
    at Browser_mainLoop_runner (blob:http://127.0.0.1/d05375fb-4c26-4487-b2f5-4da97ff15bf5:3:193392)

解决方案:1. 询问了国际友人


,他建议勾选 development, 结果并没什么用.


2. 老方法,剔除插件。 搞了几个小时,最后找到是 besthttp 所导致,我升级besthttp2_2.6.3,正常工作。
一共花了一天。
不管是堆栈信息抓包 也没法定位。只知道UnityWebRequestAssetBundle.GetAssetBundle(url) 就出错。只能一步一步的排查。
排查方法》创建一个空项目,把老项目的插件全部导入,不导入代码。在编写一个简单代码(UnityWebRequestAssetBundle.GetAssetBundle(url))测试。这样比在老项目中排查 不知道快了多少倍。
页: [1]
查看完整版本: unity2022 webgl 加载资源出错 exception thrown: TypeError ...