Closed homanp closed 8 years ago
I was able to fetch ~2500 contacts on my simulator and device.
Are you fetching the phone numbers as well, via #1?
Also, do many of the contacts have thumbnails?
Yeah, with phone numbers. Not that many have thumbs. Could you run the simulator with my branch. To test with your 2500 contacts?
You bet. I'll test it shortly.
If you don't return the phone numbers do you still hit a memory limit?
Don't know. A user that filed the bug. Tested to on 300 contacts only. I'm afk but will test when I get to my computer
Tested on both master and your branch. They both work fine with ~2500 contacts.
It might be what you're trying to do with the contacts after they are fetched.
Can you try and see if you can fetch the contacts okay without doing any manipulation afterwards?
Yeah, after fetching I just save it to my store in React. Really strange.
getPhoneContacts() { let self = this; PhoneContacts.requestAccessToContacts((userCanAccessContacts) => { if (userCanAccessContacts) { PhoneContacts.getContacts((err, contacts) => { if (err) return; ContactStore.setPhoneContacts(contacts); }); } else { AlertIOS.alert( "Can't Access Your Contacts", "Click on Open Settings and allow ntwrk to access your Contacts.\n" + "\n" + "Then come back!", [ {text: 'Open Settings', onPress: () => Contacts.openPrivacySettings() }, {text: "Later"} ] ) } }); }
Can you do a 'console.log(contacts)' right before 'if (err) return;' and see if your Chrome log shows the contact objects?
@joshuapinter How did you import 2500 contacts into the simulator?
I would like to do the same thing to check what's happening with the memory.
@homanp Good question. By default it doesn't have very many. I ended up syncing my iCloud contacts into my simulator.
This StackOverflow Answer is where I got the idea from: http://stackoverflow.com/a/32783266/293280
@joshuapinter cool. I added about 800 contacts and I'm getting this
And the stacktrace
libswiftCore.dylib`function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> ():
0x107e73180 <+0>: pushq %rbp
0x107e73181 <+1>: movq %rsp, %rbp
0x107e73184 <+4>: pushq %rbx
0x107e73185 <+5>: pushq %rax
0x107e73186 <+6>: movq %rcx, %r10
0x107e73189 <+9>: testb $0x1, %dl
0x107e7318c <+12>: jne 0x107e731aa ; <+42>
0x107e7318e <+14>: testq %rsi, %rsi
0x107e73191 <+17>: js 0x107e731f9 ; <+121>
0x107e73193 <+19>: addq %rdi, %rsi
0x107e73196 <+22>: movzbl %r9b, %eax
0x107e7319a <+26>: movq %r10, %rdx
0x107e7319d <+29>: movq %r8, %rcx
0x107e731a0 <+32>: movl %eax, %r8d
0x107e731a3 <+35>: callq 0x107eccea0 ; function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded> of Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> ()).(closure #2)
-> 0x107e731a8 <+40>: ud2
0x107e731aa <+42>: movq $0x0, -0x10(%rbp)
0x107e731b2 <+50>: movl %edi, %eax
0x107e731b4 <+52>: cmpq %rax, %rdi
0x107e731b7 <+55>: jne 0x107e73303 ; <+387>
0x107e731bd <+61>: cmpl $0xd7ff, %edi ; imm = 0xD7FF
0x107e731c3 <+67>: ja 0x107e73222 ; <+162>
0x107e731c5 <+69>: xorl %esi, %esi
0x107e731c7 <+71>: cmpl $0x80, %edi
0x107e731cd <+77>: movl $0x0, %r11d
0x107e731d3 <+83>: jb 0x107e732f6 ; <+374>
0x107e731d9 <+89>: movl %edi, %r11d
0x107e731dc <+92>: shrl $0x6, %r11d
0x107e731e0 <+96>: cmpl $0x800, %edi ; imm = 0x800
0x107e731e6 <+102>: jae 0x107e7329b ; <+283>
0x107e731ec <+108>: orb $-0x40, %r11b
0x107e731f0 <+112>: xorl %esi, %esi
0x107e731f2 <+114>: xorl %ebx, %ebx
0x107e731f4 <+116>: jmp 0x107e732c6 ; <+326>
0x107e731f9 <+121>: leaq 0xd3d92(%rip), %rdi ; "fatal error"
0x107e73200 <+128>: leaq 0xd3f89(%rip), %rcx ; "UnsafeBufferPointer with negative count"
0x107e73207 <+135>: movl $0xb, %esi
0x107e7320c <+140>: movl $0x2, %edx
0x107e73211 <+145>: movl $0x27, %r8d
0x107e73217 <+151>: movl $0x2, %r9d
0x107e7321d <+157>: callq 0x107e73180 ; <+0>
0x107e73222 <+162>: cmpl $0xe000, %edi ; imm = 0xE000
0x107e73228 <+168>: jb 0x107e73272 ; <+242>
0x107e7322a <+170>: cmpl $0x110000, %edi ; imm = 0x110000
0x107e73230 <+176>: jae 0x107e73352 ; <+466>
0x107e73236 <+182>: movl %edi, %r11d
0x107e73239 <+185>: shrl $0x6, %r11d
0x107e7323d <+189>: movl %edi, %eax
0x107e7323f <+191>: shrl $0xc, %eax
0x107e73242 <+194>: cmpl $0xffff, %edi ; imm = 0xFFFF
0x107e73248 <+200>: jbe 0x107e732a0 ; <+288>
0x107e7324a <+202>: movl %edi, %ecx
0x107e7324c <+204>: shrl $0x12, %ecx
0x107e7324f <+207>: orl $0xf0, %ecx
0x107e73255 <+213>: movzbl %cl, %edx
0x107e73258 <+216>: cmpl %edx, %ecx
0x107e7325a <+218>: jne 0x107e73303 ; <+387>
0x107e73260 <+224>: andb $0x3f, %al
0x107e73262 <+226>: orb $-0x80, %al
0x107e73264 <+228>: movzbl %cl, %edx
0x107e73267 <+231>: movq %rdx, -0x10(%rbp)
0x107e7326b <+235>: movl $0x1, %esi
0x107e73270 <+240>: jmp 0x107e732a6 ; <+294>
0x107e73272 <+242>: leaq 0xd3d19(%rip), %rdi ; "fatal error"
0x107e73279 <+249>: leaq 0xd4a80(%rip), %rcx ; "high- and low-surrogate code points are not valid Unicode scalar values"
0x107e73280 <+256>: movl $0xb, %esi
0x107e73285 <+261>: movl $0x2, %edx
0x107e7328a <+266>: movl $0x47, %r8d
0x107e73290 <+272>: movl $0x2, %r9d
0x107e73296 <+278>: callq 0x107e73180 ; <+0>
0x107e7329b <+283>: movl %edi, %eax
0x107e7329d <+285>: shrl $0xc, %eax
0x107e732a0 <+288>: orb $-0x20, %al
0x107e732a2 <+290>: xorl %esi, %esi
0x107e732a4 <+292>: xorl %edx, %edx
0x107e732a6 <+294>: leaq (,%rsi,8), %rcx
0x107e732ae <+302>: andb $0x3f, %r11b
0x107e732b2 <+306>: orb $-0x80, %r11b
0x107e732b6 <+310>: movzbl %al, %ebx
0x107e732b9 <+313>: shlq %cl, %rbx
0x107e732bc <+316>: orq %rdx, %rbx
0x107e732bf <+319>: movq %rbx, -0x10(%rbp)
0x107e732c3 <+323>: incq %rsi
0x107e732c6 <+326>: movl $0x8, %ecx
0x107e732cb <+331>: movq %rsi, %rax
0x107e732ce <+334>: mulq %rcx
0x107e732d1 <+337>: jo 0x107e73303 ; <+387>
0x107e732d3 <+339>: cmpq $0x3f, %rax
0x107e732d7 <+343>: ja 0x107e73329 ; <+425>
0x107e732d9 <+345>: andl $0x3f, %edi
0x107e732dc <+348>: orq $0x80, %rdi
0x107e732e3 <+355>: movzbl %r11b, %r11d
0x107e732e7 <+359>: movb %al, %cl
0x107e732e9 <+361>: shlq %cl, %r11
0x107e732ec <+364>: orq %rbx, %r11
0x107e732ef <+367>: movq %r11, -0x10(%rbp)
0x107e732f3 <+371>: incq %rsi
0x107e732f6 <+374>: movl $0x8, %ecx
0x107e732fb <+379>: movq %rsi, %rax
0x107e732fe <+382>: mulq %rcx
0x107e73301 <+385>: jno 0x107e73305 ; <+389>
0x107e73303 <+387>: ud2
0x107e73305 <+389>: cmpq $0x40, %rax
0x107e73309 <+393>: jae 0x107e73329 ; <+425>
0x107e7330b <+395>: movzbl %dil, %edx
0x107e7330f <+399>: movb %al, %cl
0x107e73311 <+401>: shlq %cl, %rdx
0x107e73314 <+404>: orq %r11, %rdx
0x107e73317 <+407>: movq %rdx, -0x10(%rbp)
0x107e7331b <+411>: leaq -0x10(%rbp), %rdi
0x107e7331f <+415>: leaq 0x1(%rsi,%rdi), %rsi
0x107e73324 <+420>: jmp 0x107e73196 ; <+22>
0x107e73329 <+425>: leaq 0xd3c62(%rip), %rdi ; "fatal error"
0x107e73330 <+432>: leaq 0xd3df9(%rip), %rcx ; "shift amount is larger than type size in bits"
0x107e73337 <+439>: movl $0xb, %esi
0x107e7333c <+444>: movl $0x2, %edx
0x107e73341 <+449>: movl $0x2d, %r8d
0x107e73347 <+455>: movl $0x2, %r9d
0x107e7334d <+461>: callq 0x107e73180 ; <+0>
0x107e73352 <+466>: leaq 0xd3c39(%rip), %rdi ; "fatal error"
0x107e73359 <+473>: leaq 0xd49f0(%rip), %rcx ; "value is outside of Unicode codespace"
0x107e73360 <+480>: movl $0xb, %esi
0x107e73365 <+485>: movl $0x2, %edx
0x107e7336a <+490>: movl $0x25, %r8d
0x107e73370 <+496>: movl $0x2, %r9d
0x107e73376 <+502>: callq 0x107e73180 ; <+0>
0x107e7337b <+507>: nopl (%rax,%rax)
No idea. Can you do some more diagnostics:
1) Try commenting out the thumbnail image data stuff and see if it returns the contacts okay.
2) Try limiting the number of contacts to see if that's an issue.
3) Try handling the error and setting a breakpoint to see if it's a particular contact's thumbnail that is causing the problem.
1) Commented out the thumbnail stuff and everything works fine.
2) Limiting number of contacts does not help
Will try to handle the error and see what I come up with.
@joshuapinter after examining the code I found out that thumbnailImageData
can be nil even if 'imageDataAvailable' is True
. I made a pull request for the fix here: #3
Good catch @homanp! I merged #3 so I'll close this Issue. 👍
@joshuapinter thanks, I filed a bug to iOS team as well.
Perfect.
Did you happen to test if cNContact.imageData
was nil
when the cNContact.imageDataAvailable
was true
but cNContact.thumbnailImageData
was nil
?
I did not test if imageData was present or not. That could've been the issue as well. I can test it and get back to you today
Sounds good. Would be nice to know to further figure out the value of imageDataAvailable
.
Seems like the app is crashing due to memory when fetching > 800 contacts. Any idea on how to fix this?
/ Ismail