Steps to Reproduce
[DllImport("myclib")] private static extern void drawLine(IntPtr ptr, float x0, float y0, float x1, float y1, IntPtr ptr2); static int Main(string[] args) { using (var reader = new StringReader("")) { for (int i = 0; i < 1000; i++) { for (double d = 0; d < 1000; d += 5) drawLine(IntPtr.Zero, 0, 0, 1, 1, IntPtr.Zero); for (double d = 0; d < 1000; d += 5) drawLine(IntPtr.Zero, 0, 0, 1, 1, IntPtr.Zero); } } return 0; }
#include <stdio.h> extern "C" { void drawLine(void *ptr, float x0, float y0, float x1, float y1, void *ptr2) { } }
Statically link the file with the packager.
The signature has to be VIFFFFI
(it’s not available in mono master, should be added by #19671), the x1
and y1
have to be 1, there has to be a using around the usage.
A different cookie signature, a zero as x1/y1 or no using does not fail.
And debugging has to be enabled.
Current Behavior
In some memory intensive conditions, using SkiaSharp for WebAssembly, the following error happens randomly:
Uncaught RuntimeError: memory access out of bounds
at do_rehash.1 (<anonymous>:wasm-function[19902]:0x5404ea)
at rehash.2 (<anonymous>:wasm-function[19901]:0x540489)
at monoeg_g_hash_table_insert_replace (<anonymous>:wasm-function[19900]:0x540365)
at mono_debug_add_method (<anonymous>:wasm-function[16551]:0x4cd0f4)
at interp_save_debug_info (<anonymous>:wasm-function[12589]:0x430caa)
at generate (<anonymous>:wasm-function[12584]:0x430707)
at mono_interp_transform_method (<anonymous>:wasm-function[12583]:0x4300a4)
at do_transform_method (<anonymous>:wasm-function[12429]:0x419a46)
at interp_exec_method (<anonymous>:wasm-function[12376]:0x409333)
at interp_runtime_invoke (<anonymous>:wasm-function[12374]:0x40923a)
Without the debugger, the crash location is :
Uncaught RuntimeError: memory access out of bounds
at monoeg_g_hash_table_lookup_extended (<anonymous>:wasm-function[19900]:0x4c3ad9)
at monoeg_g_hash_table_lookup (<anonymous>:wasm-function[19901]:0x4c3b3a)
at find_cached_memberref_sig (<anonymous>:wasm-function[15811]:0x444184)
at method_from_memberref (<anonymous>:wasm-function[15823]:0x44514d)
at mono_get_method_from_token (<anonymous>:wasm-function[15821]:0x444e83)
at mono_get_method_checked (<anonymous>:wasm-function[15820]:0x444ac6)
at interp_get_method (<anonymous>:wasm-function[12557]:0x3ce7c1)
at interp_transform_call (<anonymous>:wasm-function[12548]:0x3cd337)
at generate_code (<anonymous>:wasm-function[12533]:0x3c3008)
at generate (<anonymous>:wasm-function[12578]:0x3cfdc4)
Expected Behavior
No error happens.
On which platforms did you notice this
[ ] macOS
[ ] Linux
[ ] Windows
Version Used: e934687
Binaries repo
workAot.zip
Here’s the full repro: https://github.com/jeromelaban/Wasm.Samples/tree/master/SkiaCorruption/SkiaMemoryCorruption
I was getting this error when I try to load my Web game:
My game is loaded at this domain:
Highest Flavor Website Link
This is my project settings at the time of build export:
Please give me some suggestion to solve this problem.
asked Mar 12, 2020 at 14:13
6
This error happened to me due to using the dynamic
keyword. After replacing all my dynamic
types with object
the error was gone. Apparently the dynamic
keyword is not supported on WebGL builds.
answered Sep 23, 2020 at 20:03
Endel DreyerEndel Dreyer
1,63418 silver badges27 bronze badges
I’ve finally fixed the same error in my project. Here is what i did:
-
Narrow down the line of code that crashes WebGL.
Go through the painfull process of pinpointing the line of code that
is the source of the error. I had this «luck» that error occured
when I’ve hit button and tried to load UIScene in Addition mode. So
at first I found the script in the scene which when disabled got rid
of the crash. Then I’ve repeated the steps and digged deeper into
lines. After 2 hours of builds, comments etc I’ve found that the code
was not working was setting the new color for UnityEngine.UI.Image.
Which was pretty weird because in playmode everything worked ok. -
Find solution. I think my solution might not be universal but I think there is something going in the Unity gameloop/lifecycle when running WebGL. The source of the problem was that i set the field that was storing my UI.Image in the Start method and then in some function I’ve tried to change the color.
Property was not exposed in inspector.public class ModuleUI : MonoBehaviour { Image qualityBG; void Start() { qualityBG = GetComponent<Image>(); } ...
then this line below was the cause of the crash
public void Set(Module module)
{
...
qualityBG.color = module.Quality.ToColor();
}
- Fixing — so I’ve added [SerializeField] attribute to the field and set it up in editor, dragged the Image into the inspector slot. An it fixed it. I suspect that WebGL build might perform some methods in different order, or maybe the multipleScene loaded together might to do with it. I’m not sure but the field was not set properly with previous code fot WebGL build.
Bonus:
I’ve also fixed some issues that was not critical (not crushing WebGL game) but not working properly as expected in playmode. This also has got to do with trying to set some object in Start() method and then doing something on them. The collection was not set up (probably null) in WebGL.
EffectUI[] effects;
Start()
{
effects = GetComponentsInChildren<EffectUI>();
}
void HideAllEffects()
{
if (effects != null)
for (int i = 0; i < effects.Length; ++i)
effects[i].gameObject.SetActive(false);
}
And this also started working when I’ve added [SerializeField] to effects and hook it up in the scene…
Hope this will help some of you guys & gals!
answered Jan 27, 2021 at 12:35
pawciupawciu
8259 silver badges15 bronze badges
To run this build within the web browser — I have removed all extra things related code those can’t work within the web build like in-app purchase, advertisements, leaderboard, native sharing etc…
After these things code removed from the project, I uploaded the exported build content to my hosting. Then after it started working properly.
answered Apr 5, 2020 at 17:22
SiddharthSiddharth
4,1129 gold badges44 silver badges89 bronze badges
1
Hi, I am trying to get my Unity LEGO microgame uploaded to play.unity.com.
I can build to WebGL and it uploads the game, but when I try to play it in my browser (chrome) it gives the following error:
‘An error occured running the Unity content on this page. See your browser Javascript console for more info. the error was: Uncaught RuntimeError: memory access out of bounds.’
You can try it here for yourself: https://play.unity.com/mg/lego/web-0osz7
I thought maybe the game was too heavy so I tried stripping the whole game down until there was barely anything left, but it still gives the same error when playing the uploaded build.
Edit: stripping down the game seems to work, I think I will have to rebuild and reupload untill I hit the maximum…
The chrome console shows these errors:
Uncaught RuntimeError: memory access out of bounds at <anonymous>:wasm-function[39464]:0xe48aa0 at <anonymous>:wasm-function[39463]:0xe48a33 at <anonymous>:wasm-function[39462]:0xe489c9 at <anonymous>:wasm-function[49594]:0x10a110c at <anonymous>:wasm-function[49601]:0x10a1f8f at <anonymous>:wasm-function[49599]:0x10a1a95 at <anonymous>:wasm-function[49598]:0x10a181f at <anonymous>:wasm-function[25339]:0xb97bac at dynCall_iiiii (<anonymous>:wasm-function[52471]:0x111f01b) at Object.dynCall_iiiii (blob:https://play.unity3dusercontent.com/08f085a7-7fd5-42f4-a591-d067454a8d6a:8:463265) at invoke_iiiii (blob:https://play.unity3dusercontent.com/08f085a7-7fd5-42f4-a591-d067454a8d6a:8:331727) at <anonymous>:wasm-function[50596]:0x10c8f11 at <anonymous>:wasm-function[50050]:0x10b0ed8 at <anonymous>:wasm-function[4469]:0x1b7b8d at <anonymous>:wasm-function[4467]:0x1b7865 at <anonymous>:wasm-function[8137]:0x2f5ff6 at <anonymous>:wasm-function[8134]:0x2f4e18 at <anonymous>:wasm-function[10603]:0x40081f at <anonymous>:wasm-function[8402]:0x3162cc at <anonymous>:wasm-function[10989]:0x42cea0 at <anonymous>:wasm-function[10703]:0x40a3f0 at <anonymous>:wasm-function[10703]:0x40a405 at <anonymous>:wasm-function[10698]:0x409f0f at <anonymous>:wasm-function[10691]:0x408112 at dynCall_v (<anonymous>:wasm-function[52485]:0x111f24d) at Object.dynCall_v (blob:https://play.unity3dusercontent.com/08f085a7-7fd5-42f4-a591-d067454a8d6a:8:471234) at browserIterationFunc (blob:https://play.unity3dusercontent.com/08f085a7-7fd5-42f4-a591-d067454a8d6a:8:166325) at Object.runIter (blob:https://play.unity3dusercontent.com/08f085a7-7fd5-42f4-a591-d067454a8d6a:8:169386) at Browser_mainLoop_runner (blob:https://play.unity3dusercontent.com/08f085a7-7fd5-42f4-a591-d067454a8d6a:8:167848)
I was getting this error when I try to load my Web game:
My game is loaded at this domain: Highest Flavor Website Link
This is my project settings at the time of build export:
Please give me some suggestion to solve this problem.
3 Answers 3
This error happened to me due to using the dynamic keyword. After replacing all my dynamic types with object the error was gone. Apparently the dynamic keyword is not supported on WebGL builds.
I’ve finally fixed the same error in my project. Here is what i did:
Narrow down the line of code that crashes WebGL. Go through the painfull process of pinpointing the line of code that is the source of the error. I had this «luck» that error occured when I’ve hit button and tried to load UIScene in Addition mode. So at first I found the script in the scene which when disabled got rid of the crash. Then I’ve repeated the steps and digged deeper into lines. After 2 hours of builds, comments etc I’ve found that the code was not working was setting the new color for UnityEngine.UI.Image. Which was pretty weird because in playmode everything worked ok.
Find solution. I think my solution might not be universal but I think there is something going in the Unity gameloop/lifecycle when running WebGL. The source of the problem was that i set the field that was storing my UI.Image in the Start method and then in some function I’ve tried to change the color.
Property was not exposed in inspector.
then this line below was the cause of the crash
- Fixing — so I’ve added [SerializeField] attribute to the field and set it up in editor, dragged the Image into the inspector slot. An it fixed it. I suspect that WebGL build might perform some methods in different order, or maybe the multipleScene loaded together might to do with it. I’m not sure but the field was not set properly with previous code fot WebGL build.
Bonus: I’ve also fixed some issues that was not critical (not crushing WebGL game) but not working properly as expected in playmode. This also has got to do with trying to set some object in Start() method and then doing something on them. The collection was not set up (probably null) in WebGL.
And this also started working when I’ve added [SerializeField] to effects and hook it up in the scene.
Memory access out of bounds как исправить
I was getting this error when I try to load my Web game:
My game is loaded at this domain: Highest Flavor Website Link
This is my project settings at the time of build export:
Please give me some suggestion to solve this problem.
3 Answers 3
I’ve finally fixed the same error in my project. Here is what i did:
Narrow down the line of code that crashes WebGL. Go through the painfull process of pinpointing the line of code that is the source of the error. I had this «luck» that error occured when I’ve hit button and tried to load UIScene in Addition mode. So at first I found the script in the scene which when disabled got rid of the crash. Then I’ve repeated the steps and digged deeper into lines. After 2 hours of builds, comments etc I’ve found that the code was not working was setting the new color for UnityEngine.UI.Image. Which was pretty weird because in playmode everything worked ok.
Find solution. I think my solution might not be universal but I think there is something going in the Unity gameloop/lifecycle when running WebGL. The source of the problem was that i set the field that was storing my UI.Image in the Start method and then in some function I’ve tried to change the color.
Property was not exposed in inspector.
then this line below was the cause of the crash
- Fixing — so I’ve added [SerializeField] attribute to the field and set it up in editor, dragged the Image into the inspector slot. An it fixed it. I suspect that WebGL build might perform some methods in different order, or maybe the multipleScene loaded together might to do with it. I’m not sure but the field was not set properly with previous code fot WebGL build.
Bonus: I’ve also fixed some issues that was not critical (not crushing WebGL game) but not working properly as expected in playmode. This also has got to do with trying to set some object in Start() method and then doing something on them. The collection was not set up (probably null) in WebGL.
And this also started working when I’ve added [SerializeField] to effects and hook it up in the scene.
Memory access out of bounds error when using _malloc on WASM compiled code #5161
I have successfully compiled stb_dxt , a DXT texture compressor written in C++, to emscripten and asm.js . This works wonderfully in Firefox but performance in Chrome is poor. I am therefore attempting to compile the same program to WebAssembly using the following flags:
emcc -O3 stb_dxt.cpp -o dxt.js -s DISABLE_EXCEPTION_CATCHING=1 -s NO_FILESYSTEM=1 -s EXPORTED_FUNCTIONS=»[‘_rygCompress’]» -s WASM=1 -s ALLOW_MEMORY_GROWTH=1
My Javascript glue code, which works perfectly with asm.js , needs to pass in an image ArrayBuffer like so:
As you can see I am using _malloc to allocate the memory for the passed in ArrayBuffer and also for what will be the resulting output ArrayBuffer once the program has run and compressed the texture to DXT1.
However, as soon as the first call to _malloc fires, I am getting an out of bounds memory error:
I assume that I’m doing something wrong, any help would be greatly appreciated.
Memory access out of bounds как исправить
«RuntimeError: memory access out of bounds» error is thrown when running a WebGL build on Chrome via a file:// path using —allow-file-access-from-files
How to reproduce:
1. Close any active instances of Google Chrome
2. Open a Terminal window
3. Type «open -a «Google Chrome» —args —allow-file-access-from-files» and press Enter
4. In the attached build «Build 2019.4.33f1», open «index.html» with Google Chrome
Expected result: The build displays the «test.png» image
Actual result: The build shows a blank screen
Reproducible with: 2019.4.33f1, 2020.1.0a6
Could not test with: 2020.1.0a7, 2020.3.23f1, 2021.2.3f1, 2022.1.0a15 (Error: Ensure CORS requests are made on supported schemes)
Notes:
1. Reproduced on Chrome Version 96.0.4664.55
2. The build works as expected when running from a local server
3. The error is not reproducible on any Unity version and works as expected with Firefox
Errors in Chrome’s Console:
UnityLoader.js:1150 exception thrown: RuntimeError: memory access out of bounds,RuntimeError: memory access out of bounds
Invoking error handler due to
Uncaught RuntimeError: memory access out of bounds
Resolution Note (2022.2.X):
Thank you for opening the bug. However, the Unity WebGL build target is designed for usage via a web server. We are unable to provide workarounds for browser limitations when accessing content locally via a file:// url.
Загрузка…