Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
3
Question by VRinteractive · Dec 21, 2020 at 05:54 PM · webplayerwebglwwwdownloadbrowser

WebGL: RuntimeError: memory access out of bounds.

Hello to everybody, so im facing this error "Runtime Error: memory access out of bounds." when i run my webGL build on some mobile browsers.


  • These are my tests:

  • Fail: Chrome for android, version 87.0.4280.101 (latest stable until now);

  • Success: Firefox for android, version 84.1.1 (latest stable until now);

  • Fail: Safari for iOS (latest stable version);

  • Fail: Chrome for iOS (latest stable version);

  • Fail: Firefox for iOS (latest stable version);

  • On desktop, works correctly on any browser.


    How do i generate this error:

Just by running a WWW or UnityWebRequest to download a file data like this:

 byte[] data = null;
 WWW www = new WWW(url);
 yield return www;
 if (www.error != null)
     throw new Exception(www.error);
 else
     data = www.bytes;
         
 print(www.text.Length);//Printing the text lenght give the error
 print(data.Length);//Printing the bytes lenght doesnt give the error


Note: it happens only with files that are like 10/20MB or heavier, i've tried with a file that is less than 1MB and it works correctly on all the mobile browsers. I already read that a solution should be by increasing the memory allocation / memory heap, but i didnt understand how.

i already tried this and many other ways:

  var maxHeapSize = 256 * 1024 * 1024;
  UnityEditor.PlayerSettings.WebGL.emscriptenArgs = string.Format("-s WASM_MEM_MAX={0} -s ALLOW_MEMORY_GROWTH=1", maxHeapSize);

and this too:

 UnityEditor.PlayerSettings.WebGL.memorySize = 1024;

But nothing changes, the error is still showing. And yes, i tried even with UnityWebRequest but still same error.


Ps: Actually i dont need to print the text lenght, but since i need to access to that string, the error will be given anyway even just for a simple access to the string (i guess its because the string is too large and so i should allocate memory first, BUT HOW?)


  • My Unity3D version is: 2020.1.10f1

  • Player settings > Other Settings: alt text

  • Player settings > Publishing Settings: alt text


Thanks to everyone who can help me.

172901-cattura.png (14.2 kB)
172902-other.png (58.3 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CTePeoTun · Dec 24, 2020 at 12:42 PM 0
Share

I have a similar problem now. If you get an answer, then beep.

avatar image VRinteractive · Jul 23, 2021 at 08:31 PM 0
Share

Update: i've tried with the latest stable version of unity (2021.1.15f1) and there is still the same problem. Someone can help me?

Thanks.

6 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Pawciu · Jan 27, 2021 at 12:53 PM

I've finally fixed the same error in my project. Here is what i did:


1. 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.

2. 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();
    }



3. 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!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image VRinteractive · Feb 12, 2021 at 10:16 AM 0
Share

Im sorry but this one doesnt fix my issue.

avatar image
0

Answer by CTePeoTun · Dec 24, 2020 at 12:44 PM

I have a similar problem now. If you get an answer, then beep.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by VRinteractive · Jan 07, 2021 at 10:18 AM

Up .

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image VRinteractive · Jul 23, 2021 at 08:31 PM 0
Share

Update: i've tried with the latest stable version of unity (2021.1.15f1) and there is still the same problem. Someone can help me?

Thanks.

avatar image
0

Answer by astrolabe-games · Mar 21 at 10:36 AM

in my case the problem was solved with the option "full without stacktrace" in the "enable exception field" alt text


untitled.jpg (26.0 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image theylovegames · Apr 24 at 08:10 PM 0
Share

I tried Full Without Stacktrace without any luck with Unity 2021.3.1f1.

It seems that WebGL builds are throwing "out of bounds memory access" runtime errors on my iPad (9th Generation) on iOS (15.4). I tested with Chrome and Safari.

I created a bare bones repro project. It's just an empty scene with a text label. https://github.com/tgraupmann/Unity2021TestWebGL

I did a development build for WebGL.

With Enable Exceptions: "Explicitly Thrown Exceptions Only" set https://theylovegames.com/Unity2021TestWebGL/

With Enable Exceptions: "Full Without Stacktrace" set https://theylovegames.com/Unity2021TestWebGL2/

It appears to work fine on PC and Android. The iPad is my only iOS device for testing.

I ran into other issues with the new 2021 build process that were not problems in 2020. I can't have UTF8 characters in the WebGL file, even in commented out code. Otherwise the build will fail. I had cache issues where I'd remove C# scripts and they were still being compiled by the WebGL build process. I had to close the editor and delete the Library folder to clear the cache.

This says the issue may be fixed in 2022.1.0a14 which is available in the Unity Hub under Pre-releases... 2022.2.0a10 is currently available. https://issuetracker.unity3d.com/issues/webgl-runtimeerror-memory-access-out-of-bounds-when-building-and-running-build

The errors still reproduce on the latest alpha.

2022.2.0a10 - Explicitly Thrown Exceptions Only - https://theylovegames.com/Unity2021TestWebGL_A1/

2022.2.0a10 - Mem128 - https://theylovegames.com/Unity2021TestWebGL_A2/

2022.2.0a10 - Full No Stack Trace - https://theylovegames.com/Unity2021TestWebGL_A3/

avatar image
0

Answer by Damast · May 22 at 07:43 PM

Same problem Unity 2019.4.39f1 & 2022.2.0a13 "RuntimeError: Out of bounds memory access" Android, Chrome Desktop works, IOS fails

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

166 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

webgl project only runs in firefox 1 Answer

Close the web player without closing the web tab 0 Answers

webgl dont render mesh on build but on the editor it does. URP 0 Answers

WebGL Build uses old script, can't update to a newer version! 1 Answer

using Asset Bundles to reduce my WebGl build size 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges