- Home /
UnityWebRequest seems to crash application when active on Application.Quit()?
Our application on startup creates a number of UnityWebRequests to download some data. If we quit the application right after we've launched it, and the requests are still active, we seem to experience a crash. Looking at the crash dump and with Unity's symbols loaded, it seems to point at some issue related to the UnityWebRequestManager.
The exception states: "The thread tried to read from or write to a virtual address for which it does not have the appropriate access".
To try and fix the issue we've explicitly been trying to Abort all active UnityWebRequests on application quit, but this has not resolved the problem.
We're currently on Unity 5.6.5p1.
The assembly shown via crash dumps is the following:
00007FF6115694E0 lea rcx,[UnityWebRequestManager::m_ActiveDownloadScriptHandlerLock (07FF61190C500h)]
00007FF6115694E7 jmp Mutex::~Mutex (07FF610B909B0h)
00007FF6115694EC int 3
00007FF6115694ED int 3
00007FF6115694EE int 3
00007FF6115694EF int 3
00007FF6115694F0 sub rsp,28h
00007FF6115694F4 mov rax,qword ptr [UnityWebRequestManager::m_Requests (07FF61190C4A8h)]
00007FF6115694FB mov rdx,qword ptr [rax]
00007FF6115694FE mov qword ptr [rax],rax
00007FF611569501 mov rax,qword ptr [UnityWebRequestManager::m_Requests (07FF61190C4A8h)]
00007FF611569508 mov qword ptr [rax+8],rax
00007FF61156950C mov rcx,qword ptr [UnityWebRequestManager::m_Requests (07FF61190C4A8h)]
00007FF611569513 mov qword ptr [UnityWebRequestManager::m_Requests+8h (07FF61190C4B0h)],0
00007FF61156951E cmp rdx,rcx
00007FF611569521 je `memory_pool_impl<56>::get_pool'::`2'::`dynamic atexit destructor for 'pool''+45Fh (07FF61156954Fh)
00007FF611569523 mov qword ptr [rsp+20h],rbx
00007FF611569528 nop dword ptr [rax+rax]
00007FF611569530 mov rbx,qword ptr [rdx] <-------- LOCATION OF THE CRASH
00007FF611569533 mov rcx,rdx
00007FF611569536 call operator delete[] (07FF610CCD7F0h)
00007FF61156953B mov rcx,qword ptr [UnityWebRequestManager::m_Requests (07FF61190C4A8h)]
00007FF611569542 mov rdx,rbx
00007FF611569545 cmp rbx,rcx
00007FF611569548 jne `memory_pool_impl<56>::get_pool'::`2'::`dynamic atexit destructor for 'pool''+440h (07FF611569530h)
00007FF61156954A mov rbx,qword ptr [rsp+20h]
00007FF61156954F add rsp,28h
00007FF611569553 jmp operator delete[] (07FF610CCD7F0h)
00007FF611569558 int 3
00007FF611569559 int 3
00007FF61156955A int 3
00007FF61156955B int 3
00007FF61156955C int 3
00007FF61156955D int 3
00007FF61156955E int 3
00007FF61156955F int 3
00007FF611569560 sub rsp,28h
Any ideas what may cause this issue? Are UnityWebRequests supposed to gracefully handle application quits, or is there something we should do? Or am I misinterpreting the assembly shown?
Answer by jcaron · Jul 05, 2018 at 09:29 AM
I'm having a similar problem on Android, even is the WebRequest is completed. I also tried Disposing the WebRequest before quitting, same result. It seems to be related to the cache system.
public class TestWebRequest : MonoBehaviour {
UnityWebRequest request;
void Start () {
request = UnityWebRequest.GetAssetBundle("https://storage.googleapis.com/<validurlhere>", 0);
request.Send();
}
void Update () {
if (request.isDone)
Application.Quit();
}
}
here is the stack trace on Android:
07-05 10:43:57.489 14011 14111 F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x28 in tid 14111 (ReadCacheIndex)
07-05 10:43:57.578 14130 14130 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-05 10:43:57.578 14130 14130 F DEBUG : Build fingerprint: 'samsung/j5xnltexx/j5xnlte:7.1.1/NMF26X/J510FNXXS2BRA3:user/release-keys'
07-05 10:43:57.578 14130 14130 F DEBUG : Revision: '4'
07-05 10:43:57.578 14130 14130 F DEBUG : ABI: 'arm'
07-05 10:43:57.579 14130 14130 F DEBUG : pid: 14011, tid: 14111, name: ReadCacheIndex >>> com.magnificgames.magnific <<<
07-05 10:43:57.579 14130 14130 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x28
07-05 10:43:57.579 14130 14130 F DEBUG : r0 8b68d3c4 r1 00000000 r2 8fcd6050 r3 00000000
07-05 10:43:57.579 14130 14130 F DEBUG : r4 00000000 r5 8b68d830 r6 ffffe244 r7 00000028
07-05 10:43:57.579 14130 14130 F DEBUG : r8 ffffe244 r9 8b68d88c sl 8cb47b70 fp 00000014
07-05 10:43:57.579 14130 14130 F DEBUG : ip 94b1bf84 sp 8b68d3a8 lr 93b289c0 pc 93b8ad74 cpsr a00f0010
07-05 10:43:57.606 14130 14130 F DEBUG :
07-05 10:43:57.606 14130 14130 F DEBUG : backtrace:
07-05 10:43:57.607 14130 14130 F DEBUG : #00 pc 00739d74 /data/app/com.magnificgames.magnific-2/lib/arm/libunity.so (_ZNK10FileSystem10ToAbsoluteEPKc+12)
07-05 10:43:57.607 14130 14130 F DEBUG : #01 pc 006d79bc /data/app/com.magnificgames.magnific-2/lib/arm/libunity.so (_Z18IsDirectoryCreatedRKN4core12basic_stringIcNS_20StringStorageDefaultIcEEEE+64)
07-05 10:43:57.607 14130 14130 F DEBUG : #02 pc 0056b9b4 /data/app/com.magnificgames.magnific-2/lib/arm/libunity.so (_ZN5Cache22ReadCacheIndexThreadedEPv+380)
07-05 10:43:57.607 14130 14130 F DEBUG : #03 pc 00688c7c /data/app/com.magnificgames.magnific-2/lib/arm/libunity.so (_ZN6Thread16RunThreadWrapperEPv+84)
07-05 10:43:57.607 14130 14130 F DEBUG : #04 pc 00047b93 /system/lib/libc.so (_ZL15__pthread_startPv+22)
07-05 10:43:57.607 14130 14130 F DEBUG : #05 pc 00019fb1 /system/lib/libc.so (__start_thread+6)
using WWW.LoadFromCacheOrDownload also end up with the same Fatal Error on quitting the app.