- Home /
Application.OpenURL crashes Firefox on WebGL
Hi folks, I'm new to Unity.
I use following code to quit my application, but the WebGL build crashes my Firefox when I call Application.OpenURL(). WebPlayer build works fine.
void Update ()
{
// Exit game?
if (Input.GetKeyDown (KeyCode.Escape)) {
if (Application.platform == RuntimePlatform.WebGLPlayer
|| Application.platform == RuntimePlatform.WindowsWebPlayer
|| Application.platform == RuntimePlatform.OSXWebPlayer) {
// Browsers go back to home
Application.OpenURL ("http://localhost/");
}
#if UNITY_EDITOR
else if (Application.platform == RuntimePlatform.WindowsEditor
|| Application.platform == RuntimePlatform.OSXEditor) {
// Editors stop game mode
UnityEditor.EditorApplication.isPlaying = false;
}
#endif
else {
// Standalone builds just quit
Application.Quit ();
}
}
}
Is this a known issue? Or, I should not even use Application.OpenURL to quit my browser application?
Some spec reports:
Unity 5.1.0f3
Firefox 38.0.5: WebGL - Crashes on Application.OpenURL
Chrome: WebGL - Works fine
IE: WebGL - Whole app crashes (I know it's not well supported yet, so it's ok.)
We are also experiencing this. Seems like what's happening is we are leaving the page hosting the javascript of the application, but that javascript isn't stopped/released properly first.
Our solutions was to open a new window using external javascript and leave our app running...
As an update:
WebGL for FireFox:
We were able to keep this from crashes when trying to link externally by using an external call to a javaScript function, setting the canvas to display=none, pausing for a second, and then redirecting like this:
var redirectUrl = "";
function unityRedirect(url)
{
document.getElementById('canvas').style.display = 'none';
redirectUrl = url;
setTimeout(redirect, 1000);
}
function redirect()
{
document.location.href = redirectUrl;
}
The interesting thing is the WebPlayer is also causing a crash when we redirect from it's page in Firefox. The same functions did not solve that issue as it is an issue with Firefox's plugin container crashing. Please Unity fix this, the webPlayer did not used to do this.
@blurdot Thanks for the update. This is also my current solution to avoid the Firefox crash. I try to forget about WebPlayer from next projects, as it seems unity and browser vendors are deprecating it in the near future.
Answer by Schubkraft · Jul 06, 2015 at 09:57 AM
There seems indeed to be an issue. I reported it as a bug and sent it to the developers.
Answer by petrucio · Jan 18, 2016 at 07:45 PM
OpenURL indeed does not currently work on WebGL. You'll need to create a simple javascript plugin to handle onMouseUps, and handle your onMouseDowns to send events to said plugin. It sounds complicated, but it's simple once you get it. But you'll probably lose a couple hours to get it working the first time: http://va.lent.in/opening-links-in-a-unity-webgl-project/
Your answer
Follow this Question
Related Questions
WebGL Input - KeypadEnter registering as Return 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
AWS Cognito Not Working with WebGL 0 Answers