Hi,
we are using Unity 2017.4.10f1.
Application.Quit does not seem to work when I compile for UWP (IL2CPP). Is this a known issue?
Thanks
Jus
Hi,
we are using Unity 2017.4.10f1.
Application.Quit does not seem to work when I compile for UWP (IL2CPP). Is this a known issue?
Thanks
Jus
update:
I found issue 1065223.
We are also using Unity IAP. When will this bug be fixed?
The bug in question is fixed internally and we’re in the process of backporting it to 2017.4 and 2018.2. Unfortunately I can’t give you any dates.
Do you suffer the same symptoms of the game freezing when trying to quit?
Fortunately, the bug was located in the public source code, so if you need the fix sooner, you should be able to workaround it with this patch diff:
diff --git a/libil2cpp/vm/ScopedThreadAttacher.h b/libil2cpp/vm/ScopedThreadAttacher.h
--- a/libil2cpp/vm/ScopedThreadAttacher.h
+++ b/libil2cpp/vm/ScopedThreadAttacher.h
@@ -11,30 +11,20 @@ namespace vm
{
public:
ScopedThreadAttacher()
-#if !IL2CPP_HAS_NATIVE_THREAD_CLEANUP
: m_AttachedThread(NULL)
-#endif
{
-#if !IL2CPP_HAS_NATIVE_THREAD_CLEANUP
if (il2cpp::vm::Thread::Current() == NULL)
m_AttachedThread = il2cpp::vm::Thread::Attach(il2cpp::vm::smile:omain::GetRoot());
-#else
- il2cpp::vm::Thread::Attach(il2cpp::vm::smile:omain::GetRoot());
-#endif
}
~ScopedThreadAttacher()
{
-#if !IL2CPP_HAS_NATIVE_THREAD_CLEANUP
if (m_AttachedThread != NULL)
il2cpp::vm::Thread::smile:etach(m_AttachedThread);
-#endif
}
private:
-#if !IL2CPP_HAS_NATIVE_THREAD_CLEANUP
- Il2CppThread * m_AttachedThread;
-#endif
+ Il2CppThread* m_AttachedThread;
};
}
}
Hello I have the same issue on my game, I’m using Unity 2018.2.5f1 + Visual Studio Community 2017 15.8.1 + xbox-live-unity-plugin 1804 QFE 1 Release.
If I build my game as .NET scripting backend all works properly, the game login in the xbox live service and when I call Application.Quit() the game window close correctly. But, if I build my game as IL2CPP scripting backend when I call Application.Quit() the game window freeze and I can’t stop the game.
I have observed that if in the IL2CPP version I doesn’t login to the xbox live service the game window close correctly when I call Application.Quit().
I don’t know exactly where is the problem, can you please explain in more detail how to patch the bug ? I have tried to modify “ScopedThreadAttacher.h” but in my case doesn’t works, thank you a lot, Best regards…
Hello, I’m sorry, I have misunderstood the patch, if I modify the source file “ScopedThreadAttacher.h” as suggested the game is closed when I call Application.Quit(), thank you very much, Best regards…
Thanks for your answer.
Will wait for the official patch. It’s not urgent.
Hello, wait please, seems that there are some exceptions not handled when the game are closing, my dashboard on Windows dev center signal memory failures each time the game is closed.
I have debugged my game on Visual Studio and when I close it I have many exceptions not handled, Cheers…
What’s the callstack for that?
Hello, there are many exceptions when the game is closed, I hope that the next image is useful.
I’m using “xbox live plugin” on my game for Microsoft Store publish and the exception occours when Application.Quit() is called and the player is signed in, if the player isn’t signed in the game close properly when Application.Quit() is called (also without ScopedThreadAttacher modification), Cheers…
Unity version: Unity 2018.2.6f1
Unity Xbox Live plugin version: 1804 QFE 1 Release
Visual Studio 2017 version: 15.8.2
One thing to check: are you unsubscribing from Xbox Live events before you shutdown? It’s possible they’re calling back into you as you shut down the engine, and since C# land is shut down, you crash.
If that’s not it, could you do “DEBUG” → “Save dump as…” and send me the resulting file?
Hello, I have tried different solution but nothing, the game raise exception when Application.Quit() is called, I have also tried to unsubscribing from Xbox Live events before quit the game.
The dump file is very large, 1 GB…
I’m stuck because I can’t update my game on Microsoft Store in this way, if I build the game as .NET Scripting backend all works OK but sometimes when the player signin the game shutdown and if I build the game as .IL2CPP Scripting backend I can’t properly quit the game.
In the IL2CPP version on Windows 10 if the game is closed by X on title bar the game exit properly.
I don’t know if I’m the only one with this issue, thank you a lot for your assistance, Cheers…
PS:
The current version of the game on Microsoft Store was built with Unity 2018.1.6f1 and Unity Xbox Live plugin 1711 Release as .NET scripting backend.
Use 7-zip to compress the dump file. They usually compress really well. I can’t really help you without a dump file unfortunately
Don’t worry, I will wait the next version of Unity, in the mean time I will investigate on this issue, thank you, Cheers…
You could also report a bug with a repro if that was easier. But yeah, it’s unlikely it will be fixed without us figuring out what’s going on.
Hello, I have found a workaround, I don’t know if it is a good practice, I have added a WinRT call after Application.Quit() method and the game close without exception.
Leave ScopedThreadAttacher.h as it is after build IL2CPP, I need to do much test before confirm that it’s works properly, at the moment I haven’t found any error on Windows Dev Center, Cheers…
Hello, I have seen that is fixed in the latest release Unity 2018.2.7f1, Best regards…
(1065223) - IL2CPP : Fixed deadlock on exit when calling back to managed code on a thread that doesn’t exit before player shutdown.
Yup!
Hello, I’m sorry to signal that with the latest version of Unity 2018.2.7f1 if I run my game in DEBUG build Visual Studio generate exception when the game is closed by Application.Quit() method, in MASTER mode the game close but Windows Dev Center show a memory failure as explained before.
Without signin on xbox-live-plugin my game close poperly in DEBUG and MASTER build.
I’m using
Unity version: Unity 2018.2.7f1
Unity Xbox Live plugin version: 1804 QFE 1 Release
Visual Studio 2017 version: 15.8.3
Best regards…
Yeah, we’ll need a bug report for that. It’s a separate issue not related to original deadlock.
Hello, I have used the workaround Exit() after Quit() but I don’t know if it’s a good practice, Cheers…
Application.Quit();
#if ENABLE_WINMD_SUPPORT
Windows.ApplicationModel.Core.CoreApplication.Exit();
#endif
PS: I’m not sure but I think that there is something wrong when UWP game works with xbox live plugin.