Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Application.OpenURL(url) causes crash on UWP

Discussion in 'Windows' started by amateurd, Dec 18, 2020.

  1. amateurd

    amateurd

    Joined:
    Nov 1, 2016
    Posts:
    95
    UWP build crashes when calling OpenURL, though the web page is loaded in the browser successfully. I can't see any debugging info showing why this happens. Not specific to the URL: https://www.google.com triggers it as well.
     
    joshuaFS likes this.
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,506
    Do you have a stacktrace for the crash? Can you report a bug?
     
  3. joshuaFS

    joshuaFS

    Joined:
    Jul 23, 2018
    Posts:
    25
    I'm not the OP, but I have the same problem. Pretty simple, just an "Application.OpenURL(url)" call and it will open the browser, but it does then crash the game completely without a stack trace being sent through to the Unity logger (nothing in the UnityPlayer.log). I ran it through Visual Studio, and I am getting this as output when it crashes on my Windows 10 Pro development machine with OS build 19041.804. Project was built with Unity 2021.1.4f1


    onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\viewpositiontrackerinternal.cpp(269)\Windows.Devices.Sensors.dll!00007FFC1F852DC9: (caller: 00007FFC1F853347) Exception(3) tid(9b64) 80070490 Element not found.
    Exception thrown at 0x00007FFCA7C6D759 in GameName.exe: Microsoft C++ exception: wil::ResultException at memory location 0x000000CFBDEFD410.
    Exception thrown at 0x00007FFCA7C6D759 in GameName.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    Exception thrown at 0x00007FFCA7C6D759 (KernelBase.dll) in GameName.exe: WinRT originate error - 0x8001010E : 'The application called an interface that was marshalled for a different thread.'.
    'GameName.exe' (Win32): Loaded 'C:\Windows\System32\userenv.dll'. Symbol loading disabled by Include/Exclude setting.
    'GameName.exe' (Win32): Loaded 'C:\Windows\System32\profext.dll'. Symbol loading disabled by Include/Exclude setting.
    onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\viewpositiontrackerinternal.cpp(143)\Windows.Devices.Sensors.dll!00007FFC1F8543D0: (caller: 00007FFC1F853C8B) Exception(4) tid(9b64) 8001010E The application called an interface that was marshalled for a different thread.
    Exception thrown at 0x00007FFCA7C6D759 in GameName.exe: Microsoft C++ exception: wil::ResultException at memory location 0x000000CFBDEFD410.
    The thread 0x8f34 has exited with code 0 (0x0).
    Exception thrown at 0x00007FFCA7C6D759 in GameName.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensor.cpp(184)\Windows.Devices.Sensors.dll!00007FFC1F7B37FD: (caller: 00007FFC1F7B3FCD) Exception(5) tid(9b64) 80070490 Element not found.
    Exception thrown at 0x00007FFCA7C6D759 in GameName.exe: Microsoft C++ exception: wil::ResultException at memory location 0x000000CFBDEFD7D0.
    Exception thrown at 0x00007FFCA7C6D759 in GameName.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensorserver.cpp(74)\Windows.Devices.Sensors.dll!00007FFC1F7B2E23: (caller: 00007FFC1F7FDA61) ReturnHr(3) tid(9b64) 80070490 Element not found.
    Exception thrown at 0x00007FFCA7C6D759 in GameName.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x000000CFBDEFE7A0.
    The thread 0x87ec has exited with code 0 (0x0).
    The thread 0x85ec has exited with code 0 (0x0).
    The thread 0x8ff4 has exited with code 0 (0x0).
    The thread 0x97d4 has exited with code 0 (0x0).
    Exception thrown at 0x00007FFCAA25052A (ntdll.dll) in GameName.exe: 0xC0000008: An invalid handle was specified.

    Exception thrown at 0x00007FFCAA25052A (ntdll.dll) in GameName.exe: 0xC0000008: An invalid handle was specified.

    Exception thrown at 0x00007FFCAA25052A (ntdll.dll) in GameName.exe: 0xC0000008: An invalid handle was specified.

    Exception thrown at 0x00007FFCAA25052A (ntdll.dll) in GameName.exe: 0xC0000008: An invalid handle was specified.

    onecore\com\combase\dcomrem\preventrundownbias.cpp(1310)\combase.dll!00007FFCA937219C: (caller: 00007FFCA9371FC9) LogHr(1) tid(97cc) 80070005 Access is denied.
    The thread 0x89dc has exited with code 0 (0x0).
    The thread 0x3a0 has exited with code 0 (0x0).
    The thread 0x8558 has exited with code 0 (0x0).
    'GameName.exe' (Win32): Loaded 'C:\Windows\System32\Windows.Energy.dll'. Symbol loading disabled by Include/Exclude setting.
    The thread 0x9a70 has exited with code 0 (0x0).
    'GameName.exe' (Win32): Loaded 'C:\Windows\System32\Windows.System.Launcher.dll'. Symbol loading disabled by Include/Exclude setting.
    'GameName.exe' (Win32): Loaded 'C:\Windows\System32\msvcp110_win.dll'. Symbol loading disabled by Include/Exclude setting.
    Exception thrown at 0x00007FFC19F0BE64 (UnityPlayer.dll) in GameName.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
     
    amateurd likes this.
  4. joshuaFS

    joshuaFS

    Joined:
    Jul 23, 2018
    Posts:
    25
    FWIW, since I already was using the WSANative package, I switched to using "WSANativeLauncher.LaunchUri(url);" for UWP, and that works great with no problems at all. Clearly there is a bug in Unity causing this crash, which seems to be around trying to release an invalid reference.
     
    amateurd likes this.
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,506
    amateurd likes this.
  6. amateurd

    amateurd

    Joined:
    Nov 1, 2016
    Posts:
    95
    Yes, last time I was testing it. Could submit as a bug but tbh not had the time. Just make a simple app with a button calling OpenURL. Crashes every time, no matter what the URL.
     
  7. Ville

    Ville

    Joined:
    Oct 5, 2012
    Posts:
    19
    I'm running into this as well. Any info when it will be resolved?
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,506
    I don't think we ever received a bug report. Can you report one?
     
  9. Ville

    Ville

    Joined:
    Oct 5, 2012
    Posts:
    19
    I tried to make a test project, but it doesn't seem to crash there.
     
  10. malaikapenn

    malaikapenn

    Joined:
    Feb 13, 2020
    Posts:
    1
    I am also experiencing this error when testing on a TOUGHPAD. The app will take me to the link, but then crashes when I try to return to the application. I'm on Unity v2020.3.15f1.
     
  11. Stormbirds

    Stormbirds

    Joined:
    Mar 1, 2017
    Posts:
    1
    (Case 1382236) - Application.OpenURL(url) causes crash on UWP opened up as we are also getting this
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,506
    Thanks we'll take a look!
     
  13. AlfEspinosaN

    AlfEspinosaN

    Joined:
    Jan 14, 2019
    Posts:
    9
    What could be another possible workaround with this?? System.Diagnostics.Process.Start() doesnt seem to work either...
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,506
    You could use Windows.System.Launcher.LaunchUriAsync. Application.OpenURL on UWP is just a wrapper around it.
     
    Maeslezo and AlfEspinosaN like this.
  15. AlfEspinosaN

    AlfEspinosaN

    Joined:
    Jan 14, 2019
    Posts:
    9
    Okok. I'm trying with this:
    Code (CSharp):
    1. #if (ENABLE_WINMD_SUPPORT || UNITY_WSA || UNITY_WSA_10_0)
    2. using System;
    3. using System.Threading.Tasks;
    4. using UnityEngine;
    5.  
    6. namespace Util
    7. {
    8.     public static class UWPStartUriProcess
    9.     {      
    10.         public static async Task Start(string URL)
    11.         {
    12.             try
    13.             {
    14.                 var options = new Windows.System.LauncherOptions();
    15.                 options.TreatAsUntrusted = true;
    16.                 var success = await Windows.System.Launcher.LaunchUriAsync(URL, options);
    17.  
    18.                 if (success)
    19.                 {
    20.                     Debug.LogError("Opened - " + URL);
    21.                 }
    22.                 else
    23.                 {
    24.                     Debug.LogError("Failed to open - " + URL);
    25.                 }
    26.             }
    27.             catch (Exception e)
    28.             {
    29.                 UnityEngine.Debug.LogError("Failed to open URL: " + e);
    30.             }                    
    31.         }    
    32.     }
    33. }
    34. #endif
    I get the following error when building UWP: Assets\Scripts\Utils\UWPStartUriProcess.cs(14,72): error CS1503: Argument 1: cannot convert from 'string' to 'System.Uri'

    Do you know what could be going on? :eek:
     
    Last edited: Dec 10, 2021
  16. AlfEspinosaN

    AlfEspinosaN

    Joined:
    Jan 14, 2019
    Posts:
    9
    Can I ask from where did you get that WSANative package?
     
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,506
    You need to construct the URI using "new Uri(URL)" and pass that to the Windows API.
     
    AlfEspinosaN likes this.
  18. RendergonPolygons

    RendergonPolygons

    Joined:
    Oct 9, 2019
    Posts:
    98