Memory Access Out of Bounds - WebGL - unity3d

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.

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

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.

Related

Why the IRtcEngine instance is not created?

i'm trying to implement a voice chat in my Unity game using agora.io. I followed the official start up tutorials and I put the code below in a script attached to an empty Gameobject in the scene:
My simple start up script
So, at the Start, the IRtcEngine instance should be created as I call the IRtcEngine.GetEngine(agoraAppID) method. The problem is that, instead od returnig the instance, this method prints an error log: "Create engine failed, error code: -7"
I looked up what the error code 7 means: "A method is called before the initialization of RtcEngine. Ensure that the RtcEngineinstance is created and initialized before calling the method".
So I tried commenting everything but the line in which the IRtcEngine.GetEngine(agoraAppID) method is called, but the error still pops up. It pops up even when I play the agora demo scene "HelloUnity".
I also tried removing the agora package and importing it again. It worked because after that the instance was created correctly, but after a few times, the error started popping up again.
Unity version: 2020.3.3f1
Agora version: 3.3.1.71
What could the problem be? Is it a bug?
I had the same issue with the same error code. Closing all Unity instances and rebooting my computer was helped me.
Usually, it happens if you don't leave the channel properly. So, putting
rtcEngine?.LeaveChannel()
to
OnDestroy()
may be a good solution.
should look something like this. don't forget the variable declaration up top.
public class Launch : MonoBehaviour
{
public IRtcEngine mRtcEngine;
void Start()
{
string agoraAccountId = "4ca78bc86f23hhhhhhhhh4444444444";
if (mRtcEngine != null)
{
Debug.Log("Agora engine exists already!!");
return;
}
mRtcEngine = IRtcEngine.GetEngine(agoraAccountId);
I suggest you join the Agora slack channel (it is easy to join) where you can get answers quickly.
Please take a look at the Demo project code and watch out how the sample app handles the life cycle in Unity. In your simple script, there is no clean up code on destroy. You left certain socket/ports open on the system. That's why when you get some success on a fresh install but not the subsequent run.

Unity WebGL Mobile browser workaround and keyboard input fix?

Hey everyone so I read that unity doesn't really support mobile browsers for WebGL games. im using 2020.1.4.And sure enough, the game gets a bit distorted by not being scaled properly. it's like the camera is bigger so it shows on the screen that blue color. I tried some things, setting width and height to auto or removing config.devicePixelRatio = 1; as suggested by a friend but nope! still looks horrible! And if that wasn't enough the keyboard doesn't show up when clicking on form fields. i tried this one
https://github.com/eforerog/keyboardMobileWebGLUnity
which displayed an error when pressed on and this one
https://github.com/dantasulisses/WebMobileInputFix which just didn't even compile!
Any ideas, please?
I did my research and tried every plugin I could find. I used Unity 2020.3.28f1 and tested both on Android-phone and iPhone.Here is my report.
These plugins don't work:
https://unitylist.com/p/f58/Unity-webgl-inputfield
https://github.com/eforerog/keyboardMobileWebGLUnity
https://github.com/dantasulisses/WebMobileInputFix
This plugin works, but you should use different settings for IOS and Android on same input field game object. If you use "prompt", it works for IOS only, and "overlay" works for Android only. Look for documentation in page:
https://github.com/unity3d-jp/WebGLNativeInputField
And this plugin works best at the moment. Yes, it is a bit ugly though, but it works.
https://github.com/kou-yeung/WebGLInput
And there is a fix for Unity 2021 for it:
https://github.com/kou-yeung/WebGLInput/releases/tag/1.0
There's a keyboard that overlays, when using it you just need to tap the notification to access it and then click the "back" button to hide it https://play.google.com/store/apps/details?id=com.fishstix.gameboard
I made this project that simply recreates a keyboard using buttons in unity.
I implemented it in a WebGL build successfully.
https://github.com/thetimeste/WebGL-Build-Keyboard-Unity.git
I would recommend using the native js window.prompt() fields as of writing. They have great cross-platform support, allow for extra features like special characters, emojis, copy and paste etc. and are pretty easy to set up. Once (or honestly if ever) Unity adds their own reliable implementation you can easily remove this lightweight implementation.
Create a .jslib file that has a function opening a window.prompt(description, currentText)
Return the result at the end of that function back to a unity object with a recipient script
Make a derivation from Unity's event system overwriting the OnApplicationFocus(bool focus) function (leaving it empty), to fix a sneaky Chrome Android bug.
That's it. The result should look something like in this demo: https://pop.demo.neoludic.games
If you want to save some development time on a feature that really should just be native in Unity, you can also check out my plugin based on the method above. https://neoludic-games.itch.io/pop-input
I also need to enable mobile virtual keyboard for running webgl on mobile device.
I've tried the code from your mentioned url. It gives you some idea on how to do
it, but the code are totally buggy and unusable. Now I am trying to implement it
by myself.

Uncaught exception: abort(80) at jsStackTrace - Airconsole Unity

When i test a preview of the game in the Developer Console, the following error occurs in the browser. This occurs at the moment when it tries to request persistent data from the player. Someone knows what it is? NOTE* During development on Windows and in tests with Open Exported Port everything went well.
Complete log:
https://drive.google.com/open?id=1R4dJx4NSDDMbLirLENz_r0cgoedmS-tk
I would like to get the saved data from the main player with this code.
public void RequestPersistentData()
{
List<string> connectedUids = new List<string>();
connectedUids.Clear();
connectedUids.Add(AirConsole.instance.GetUID(AirConsole.instance.GetMasterControllerDeviceId()));
AirConsole.instance.RequestPersistentData(connectedUids);
}
First the scene is executed with AirInputManager.cs. Then the main menu scene where the MenuController script is executed is loaded (this is where the error happens). Finally, if the player finishes the game the data is stored on the champion screen where the ChampionManage.cs script runs.
More code: github
I solved it that way. In WebGL Player settings -> Publishing Settings-> Compression Format, change Gzip to Disabled. For some reason Gzip takes a long time to extract the necessary files when loading the game. And make sure that the name of the root folder where you will build the project has no blank space. "Crazy Game" (Bad). CrazyGame (Good).
To ensure it will work, make sure that the script execution order responsible for managing AirConsole runs at least -90 in Default Time. You can use the Script Execution Order settings (menu: Edit > Project Settings, then select the Script Execution Order__ category).

Unity - Deprecated EditorApplication

I just have updated my Unity to 5.3.1 and it seems like EditorApplication class is already deprecated. The Unity suggests me to use instead the EditorSceneManager.OpenScene but looks like it's not returning of type bool anymore. Therefore causing my game to stop compiling.
Any help about this?
Thanks!
Usually due to deprecated code unity itself offers some changes in your code you can make a backup and try that if unity informs you of it ,but if you want to know if it has been loaded or not you can use its return value which is a struct of type Scene.
SceneManagement.Scene newScene = EditorSceneManager.OpenScene("myScene");
if(newScene.isLoaded) {
//do something
}
There is another method also named IsVaild You Can try that too.
further doc :
http://docs.unity3d.com/ScriptReference/SceneManagement.Scene.html
It's hard to help you without any information on what you actually want to do... This link may help though, it's about upgrading to Unity 5.3.

Eclipse - Blackberry SDK - Debugging on device: "details unavailable - not supported by VM"

I'm having a strange problem while debugging my Blackberry Application on a real device (BB Bold 9700). When I debug the same application within the BB emulator, the app runs fine, but when I run it on the real device, the app behaves differently (custom painting goes completely wrong). What's even worse is that my Eclipse environment seems to be unable to view live objects correctly while being at a break point (debug time).
I've added a screenshot to illustrate the strange behaviour:
As you can see, the app stops at the breakpoint within the IF statement, but the Variables pane says that the variable "methodName" equals null. Moreover, when I want to look at the variable "methodArguments" which is of type org.json.me.JSONArray, it says "details unavailable - not supported by VM".
Does anyone know what's going on here? My app works great on the emulator, but it's currently useless on the real device.
Thanks in advance!
I think I fixed it:
The problem was that I was laying out Fields on a manager that wasn't yet added to the viewstack.
What did the trick for me was overriding onDisplay() in the manager that contained the Fields that were displayed wrong:
protected void onDisplay()
{
//Make sure superclass is called
super.onDisplay();
/*You have to call "this.setDirty(true)" when you perform layout on a
*manager that isn't added to the viewstack. Then you can use
*"this.isDirty()" to determine whether you need to re-layout the fields
*when the manager becomes visible.*/
if(this.isDirty())
{
//I'm not sure if I need to use "invokeAndWait" and not "invokeLater"
UiApplication.getUiApplication().invokeAndWait(new Runnable()
{
public void run()
{
for (int i = 0; i < getFieldCount(); i++)
{
/*This (custom) function makes sure the Field gets its
*size and position*/
layoutItem(getField(i));
}
}
});
//Make sure you set "dirty" to false, to make sure this only happens once
this.setDirty(false);
}
}
If anyone has a better solution, I'd be glad to hear it (and maybe improve my app).
org.json.me.JSONArray, it says "details unavailable - not supported by VM".
the JSON related stuff is not available on device running 4.5 and 4.6 BB OS. Import it into the code.
Download it from here.
https://github.com/douglascrockford/JSON-java
it is available as Open Source and then use it into your applications.