I am downloading user avatars from parse.com. The code sometimes downloads all Avatars, other times crashes part way through.
The crash was caused by this url:
Pasting into a browser, works fine!
Code:
local params = {}
params.response = {
filename = avatarQueue[1].filename,
baseDirectory = system.DocumentsDirectory
}
local urlSecure2 = string.gsub(avatarQueue[1].url, “http”, “https” )
print(“REQUESTING NEXT AVATAR -”,urlSecure2)
print(“Name -”,params.response.filename)
print(“Dir=”,params.response.baseDirectory)
network.request(urlSecure2,
“GET”,
avatarDownload,
params)
I also tried using network.download but also for the same problem
I am passing no nil values to cause a crash!
Logs:
Oct 02 01:11:03.170: !!! SUCCESS AVATAR DOWNLOADED
Oct 02 01:11:03.170: FileName = tfss-408d487d-5aef-433d-a2dd-568e80afe6a2-userAvatar_1443719362.png dir= userdata: 0x101a4e1eb
Oct 02 01:11:03.170: REQUESTING NEXT AVATAR - https://files.parsetfss.com/70278faa-dbb5-44ad-ba85-aee01911bf7d/tfss-93967d47-fecb-4646-9b93-79994dffab85-tfss-e6923b2e-d5bd-4034-99c0-5f2969817f80-tfss-d806fea9-4e60-47c3-afdf-866a88de31f5-userAvatar_1443523892.png
Oct 02 01:11:03.170: Name - tfss-93967d47-fecb-4646-9b93-79994dffab85-tfss-e6923b2e-d5bd-4034-99c0-5f2969817f80-tfss-d806fea9-4e60-47c3-afdf-866a88de31f5-userAvatar_1443523892.png
Oct 02 01:11:03.171: Dir= userdata: 0x101a4e1eb
Generic error: NSInvalidArgumentException: *** +[NSString stringWithUTF8String:]: NULL cString
(
0 CoreFoundation 0x00007fff87b62bd2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff9747a4fa objc_exception_throw + 48
2 CoreFoundation 0x00007fff87bc93fd +[NSException raise:format:] + 205
3 Foundation 0x00007fff9257d81d +[NSString stringWithUTF8String:] + 78
4 network.dylib 0x0000000105263656 -[NetworkRequestParameters initWithLuaState:] + 3593
5 network.dylib 0x0000000105264128 _ZN6Corona14NetworkLibrary7requestEP9lua_State + 90
6 Corona Simulator 0x0000000101992764 luaD_precall + 795
7 Corona Simulator 0x00000001019a1918 luaV_execute + 1775
8 Corona Simulator 0x0000000101992ae0 luaD_call + 111
9 Corona Simulator 0x0000000101998b22 luai_objcttry + 25
10 Corona Simulator 0x0000000101992d99 luaD_pcall + 109
11 Corona Simulator 0x000000010198ba88 lua_pcall + 100
12 Corona Simulator 0x00000001019ceac8 CoronaLuaError + 131100
13 Corona Simulator 0x00000001019ce9ef CoronaLuaError + 130883
14 network.dylib 0x0000000105262714 -[LuaCallback callWithNetworkRequestState:] + 303
15 network.dylib 0x0000000105260762 -[CoronaConnectionDelegate connectionDidFinishLoading:] + 1730
16 CFNetwork 0x00007fff8e71b711 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 69
17 CFNetwork 0x00007fff8e71b626 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 233
18 CFNetwork 0x00007fff8e71b52b -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 48
19 CFNetwork 0x00007fff8e801721 ___ZN27URLConnectionClient_Classic23_delegate_cacheTrifectaEPK20_CFCachedURLResponseU13block_pointerFvvE_block_invoke + 718
20 CFNetwork 0x00007fff8e8b4b47 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 100
21 libdispatch.dylib 0x00007fff91823453 _dispatch_client_callout + 8
22 libdispatch.dylib 0x00007fff918310bf _dispatch_block_invoke + 474
23 CFNetwork 0x00007fff8e71b3e8 _ZN19RunloopBlockContext13_invoke_blockEPKvPv + 24
24 CoreFoundation 0x00007fff87a9abd4 CFArrayApplyFunction + 68
25 CFNetwork 0x00007fff8e71b2e1 _ZN19RunloopBlockContext7performEv + 137
26 CFNetwork 0x00007fff8e71b182 _ZN17MultiplexerSource7performEv + 282
27 CFNetwork 0x00007fff8e71afa4 _ZN17MultiplexerSource8_performEPv + 72
28 CoreFoundation 0x00007fff87af8621 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
29 CoreFoundation 0x00007fff87ad7e1c __CFRunLoopDoSources0 + 556
30 CoreFoundation 0x00007fff87ad733f __CFRunLoopRun + 927
31 CoreFoundation 0x00007fff87ad6d38 CFRunLoopRunSpecific + 296
32 HIToolbox 0x00007fff8d2bed55 RunCurrentEventLoopInMode + 235
33 HIToolbox 0x00007fff8d2beb8f ReceiveNextEventCommon + 432
34 HIToolbox 0x00007fff8d2be9cf _BlockUntilNextEventMatchingListInModeWithFilter + 71
35 AppKit 0x00007fff93719f3a _DPSNextEvent + 1067
36 AppKit 0x00007fff93719369 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
37 AppKit 0x00007fff9370decc -[NSApplication run] + 682
38 AppKit 0x00007fff936d7162 NSApplicationMain + 1176
39 Corona Simulator 0x00000001018fd334 start + 52
40 ??? 0x0000000000000007 0x0 + 7
)