EddyVerbruggen / Calendar-PhoneGap-Plugin

:date: Cordova plugin to Create, Change, Delete and Find Events in the native Calendar
773 stars 402 forks source link

findEvent crashes on iOS (release 4.5.4) #338

Open rolfback opened 8 years ago

rolfback commented 8 years ago

The latest release stopped my app from working with the following code: window.plugins.calendar.findEvent('', '', '', startDate, endDate, function (allEvents) {}, function (err){});

Using PhoneGap + Ionic. config.xml: <plugin name="cordova-plugin-calendar" />

EddyVerbruggen commented 8 years ago

The crash probably depends on what data is found by the plugin - so can you tell me what events it finds and (most importantly) what the error is?

rolfback commented 8 years ago

The functions doesn't alert the error due to the crash. How can I trace what the error is then?

EddyVerbruggen commented 8 years ago

That's because it's a crash in native code, not in the www code - so you'll need to attach your phone to you machine and (if possible) open Xcode > Window > Devices > Select your phone and inspect the log at the moment of the crash.

rolfback commented 8 years ago

I'm not sure if this is what you need. Doesn't tell me that much.

skarmavbild 2016-10-11 kl 09 40 01
EddyVerbruggen commented 8 years ago

Thanks for the effort. Those iOS stacktraces are ever so helpful..

So is there a way to reproduce the issue? Clearly your search finds some event that chokes the plugin. Perhaps some recurrence rule or attendees list. If you can narrow it down to a specific event then we're halfway there..

rolfback commented 8 years ago

I had duplicate events, or more exactly, I was invited to an recurring event from a user, which calendar I can view. If I de-select the other user from Calendars in iOS, I still get the error (the other user is part of same organization and I cannot remove the calendar from my list of calendars).

From what I understand the findEvent method looks in all possible calendars, not only my "active" (which could be a nice feature in the future maybe).

rolfback commented 8 years ago

After I removed permissions for the other email address on the server I found out that all of my different gmail calendars have Holidays that have the same information and therefor crashes the app.

I suspect that even if the events have different id's they are causing the crash if the rest of the content are exactly the same?

rolfback commented 8 years ago

More info: I removed the findEvent-part and added listCalendars instead and it still crashes. I restarted the phone, deleted the app and installed it again. Two other iPhone-users doesn't have any problems at all. They also have several gmail-accounts like me. I've removed all other calendars from the server (holidays and weekno's).

The only method that doesn't close my app is openCalendar.

If I change plug-in to: <gap:plugin name="nl.x-services.plugins.calendar" /> it starts to work again. Not sure about differences between that plugin and <plugin name="cordova-plugin-calendar" />.

rolfback commented 8 years ago

Even more info, narrowing it down: I deleted all calendars except one and removed all appointments in that one. I cannot delete the iOS Holiday calendar though and not the Facebook and app integrations. Not the Contacts Birthdays either.

Important info I think: if my calendar is empty and I do an empty search (window.plugins.calendar.findEvent('','','',startDate, endDate, success, error);) it crashes BUT if I add 'aaa' to the search (window.plugins.calendar.findEvent('aaa','','',startDate, endDate, success, error);) it doesn't crash. Then I added an event called 'aaa' in my iOS cal and did the sync again and then it doesn't crash either.

My conclusion is that all the parameters cannot be empty strings? How to search for all events during a period?

jimmy-tfp commented 8 years ago

Hi,

This reproduces by:

1) adding the calendar from two gmail accounts to "Settings->Accounts" 2) make sure you have duplicate events showing in Calendar from "Holidays in United States" in Calendar 3) do a findEvent that has enough days to capture one of the dupes:

var start = new Date(); var end = new Date(); end.setDate(end.getDate() + 30); return $cordovaCalendar.findEvent({ title: '', location: '', notes: '', startDate: start, endDate: end });

this gets Halloween.

4) This crashes on line 28 of CDVJSON_private.m in cordova.

5) if you go back to 4.5.3 its fine

6) if you comment out line 441 of Calendar.m its fine

if (event.recurrenceRules != nil) { //[entry setObject:event.recurrenceRules forKey:@"rrule"]; }

Let me know if you need anything else.

Jimmy

rolfback commented 8 years ago

Thank you for digging into the problem. As you pointed out, the prev. version works fine.

For you who also gets this error, please delete the app from your phone and reinstall it again with 4.5.3 version: <plugin name="cordova-plugin-calendar" spec="4.5.3" />

EddyVerbruggen commented 8 years ago

Hmm that line was added through PR #337 .. let's comment it. Thanks @rolfback!

tobiasmuecksch commented 7 years ago

Is there anything new on this issue? I have the same problem...

c0bra commented 7 years ago

Still cashing. iOS simulator 10.3. My call looked like calendar.findEvent("string"). Fresh xcode install; no events have been scheduled yet.

Here's the debug log:

Aug 18 08:41:51 LT-SV-BrianH-rMBP SeniorVu[46656]: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull doubleValue]: unrecognized selector sent to instance 0x104e1e180'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x0000000104b61b0b __exceptionPreprocess + 171
        1   libobjc.A.dylib                     0x000000010459d141 objc_exception_throw + 48
        2   CoreFoundation                      0x0000000104bd1134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
        3   CoreFoundation                      0x0000000104ae8840 ___forwarding___ + 1024
        4   CoreFoundation                      0x0000000104ae83b8 _CF_forwarding_prep_0 + 120
        5   SeniorVu                            0x0000000102f5e887 __33-[Calendar findEventWithOptions:]_block_invoke + 55
        6   libdispatch.dylib                   0x0000000106bc6585 _dispatch_call_block_and_release + 12
        7   libdispatch.dylib                   0x0000000106be7792 _dispatch_client_callout + 8
        8   libdispatch.dylib                   0x0000000106bcdeb6 _dispatch_queue_override_invoke + 763
        9   libdispatch.dylib                   0x0000000106bcf899 _dispatch_root_queue_drain + 813
        10  libdispatch.dylib                   0x0000000106bcf50d _dispatch_worker_thread3 + 113
        11  libsystem_pthread.dylib             0x0000000107051746 _pthread_wqthread + 1299
        12  libsystem_pthread.dylib             0x0000000107051221 start_wqthread + 13
    )
Aug 18 08:41:51 --- last message repeated 1 time ---
Aug 18 08:41:51 LT-SV-BrianH-rMBP SpringBoard[42617]: UNSUserNotificationServerConnectionListener connection invalidated
Aug 18 08:41:51 LT-SV-BrianH-rMBP SpringBoard[42617]: [KeyboardArbiter] HW kbd: Failed to set (null) as keyboard focus
Aug 18 08:41:51 LT-SV-BrianH-rMBP com.apple.CoreSimulator.SimDevice.1A5553C1-2F43-449E-A284-4B27A4C1D20D.launchd_sim[42600] (UIKitApplication:com.softvu.seniorvu[0xe07][42622][46656]): Service exited due to Abort trap: 6
Aug 18 08:41:51 LT-SV-BrianH-rMBP backboardd[42618]: [Common] Unable to get short BSD proc info for 46656: No such process
Aug 18 08:41:51 LT-SV-BrianH-rMBP backboardd[42618]: [Common] Unable to get proc info for 46656: Undefined error: 0
Aug 18 08:41:52 LT-SV-BrianH-rMBP systemsoundserver-simd[45651]: [aqme] 254: AQDefaultDevice (173): skipping input stream 0 0 0x0
Aug 18 08:41:52 LT-SV-BrianH-rMBP assertiond[42622]: Deleted job with label: UIKitApplication:com.softvu.seniorvu[0xe07][42622]
Aug 18 08:41:52 LT-SV-BrianH-rMBP watchlistd[42707]: Now playing app did change to '(null)' (playing: 0) from '(null)'
Aug 18 08:41:52 LT-SV-BrianH-rMBP watchlistd[42707]: WLKPlaybackSummary - Parameter failed validation bundleID. It is nil
Aug 18 08:41:54 LT-SV-BrianH-rMBP systemsoundserver-simd[45651]: [aqme] 254: AQDefaultDevice (173): skipping input stream 0 0 0x0
Aug 18 08:41:58 --- last message repeated 2 times ---
Aug 18 08:41:58 LT-SV-BrianH-rMBP videosubscriptionsd[47530]: Entering main() for videosubscriptionsd.
Aug 18 08:41:58 LT-SV-BrianH-rMBP videosubscriptionsd[47530]: Unable to find framework using path: /System/Library/Frameworks/VideoSubscriberAccount.framework
Aug 18 08:41:58 LT-SV-BrianH-rMBP com.apple.CoreSimulator.SimDevice.1A5553C1-2F43-449E-A284-4B27A4C1D20D.launchd_sim[42600] (com.apple.videosubscriptionsd[47530]): Service exited with abnormal code: 1
Aug 18 08:41:58 LT-SV-BrianH-rMBP com.apple.CoreSimulator.SimDevice.1A5553C1-2F43-449E-A284-4B27A4C1D20D.launchd_sim[42600] (com.apple.videosubscriptionsd): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Aug 18 08:42:00 LT-SV-BrianH-rMBP systemsoundserver-simd[45651]: [aqme] 254: AQDefaultDevice (173): skipping input stream 0 0 0x0
Aug 18 08:42:08 --- last message repeated 4 times ---
Aug 18 08:42:08 LT-SV-BrianH-rMBP videosubscriptionsd[47612]: Entering main() for videosubscriptionsd.
Aug 18 08:42:08 LT-SV-BrianH-rMBP videosubscriptionsd[47612]: Unable to find framework using path: /System/Library/Frameworks/VideoSubscriberAccount.framework
Aug 18 08:42:08 LT-SV-BrianH-rMBP com.apple.CoreSimulator.SimDevice.1A5553C1-2F43-449E-A284-4B27A4C1D20D.launchd_sim[42600] (com.apple.videosubscriptionsd[47612]): Service exited with abnormal code: 1
Aug 18 08:42:08 LT-SV-BrianH-rMBP com.apple.CoreSimulator.SimDevice.1A5553C1-2F43-449E-A284-4B27A4C1D20D.launchd_sim[42600] (com.apple.videosubscriptionsd): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Aug 18 08:42:10 LT-SV-BrianH-rMBP systemsoundserver-simd[45651]: [aqme] 254: AQDefaultDevice (173): skipping input stream 0 0 0x0
patrickeddy commented 6 years ago

I managed to get it working with

this.calendar.findEvent('Event Title', '', '', moment().hours(0).minutes(0).toDate(), moment().hours(23).minutes(59).toDate()

I wanted to grab all of the events for the day. I'm using moment.js, but of course you can form using a normal date object as well.

joelebeau1 commented 6 years ago

After seeing related issue #268 I realized my notes field did have a line break in it. I changed it to an empty string and it's no longer crashing the iOS simulator.