facebook twitter hatena line email

「Unity/負荷軽減/WebGL」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(他調査)
(OutOfMemoryのログ)
行42: 行42:
 
</pre>
 
</pre>
 
参考:https://jpn.itlibra.com/article?id=10941
 
参考:https://jpn.itlibra.com/article?id=10941
 +
 +
参考:https://nichijou-graffiti.com/dmm-browser-game-out-of-memory-message/
  
 
==参考==
 
==参考==

2021年6月3日 (木) 17:58時点における版

範囲外のメモリアクセスのエラーを受け取る

UnityLoader.Error.handler = function(e, t)
{
    if (e.message.indexOf("memory access out of bounds") != -1)
    {
        console.log("message=" + e.message);
    }
};

"Uncaught RuntimeError: memory access out of bounds"のエラーを受け取れる

範囲外のメモリアクセスを引き起こす

Unity2019の場合

var unityInstance = UnityLoader.instantiate("unityContainer", "Build/webgl_project.json", {
    onProgress: UnityProgress,
    Module: { TOTAL_STACK: 9 * 1024  }
});
setInterval(function() {
    var text = "";
    for (var i = 0; i < 1 * 1024 * 1024; i++) {
      text += "a";
    }
    unityInstance.SendMessage('MyGameObject', 'MyFunction', text);
}, 10000);

参考:https://qiita.com/kingyo222/items/1995383a394251abd86d

他調査

throw new OutOfMemoryException();を実行すると以下エラーが起こる。他のでも起こるかも?だが・・

Uncaught undefined - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.

OutOfMemoryのログ

Out of memory. は、それはそれでエラーメッセージがある?

Out of memory. 
If you are the developer of this content, 
try allocating more memory to your WebGL build in the WebGL player settings.

参考:https://jpn.itlibra.com/article?id=10941

参考:https://nichijou-graffiti.com/dmm-browser-game-out-of-memory-message/

参考

メモリ変更:Player Settings/Publishing Setting/Memory Size(2018,2019では欄がない?) https://www.hanachiru-blog.com/entry/2019/10/04/000000

Loader.jsのソース https://gist.github.com/kyptov/f7e4718ee93b5c42bb975bc006fb10b4

Unity Playerの設定(TOTAL_MEMORYプロパティ)を外部から書き換えれば起こりづらくなる。 http://blog.livedoor.jp/hofupifoba/archives/17053937.html

htmlのBuildのjson内に、TOTAL_MEMORYというプロパティがあるので数値を直接修正できる。 https://jpn.itlibra.com/article?id=10941