Datepicker iOS 14 crashes on completely empty project

Hi,

In my project I noticed that date-picker component keeps crashing on a specific dates.
Sending this error message:
"Invalid calculation: number of calculated days is not dividable by the number of days in a week.'"

Initially I thought it's something with my project and so on. But after that I had created a new project without any lines of code.

Steps to reproduce the error:
  1. Create new Xcode project

  2. Open Main.storyboard

  3. Drag datepicker from the "+"

  4. Run project

  5. tap over the datepicker and scroll to 1996

Note: This happens only if the date picker is with preferred style: compact and/or inline (default options).

youtu.be/hjskPTB0Ok8

I am using:
Big sur 11.2
Xcode Version 12.4 (12D4e)
Answered by Claude31 in 660604022
I looked at video and did the test with the same DatePicker configuration.

No crash.

I tested with 12Pro simulator. No crash.

Could you post the complete crash log, it is not possible to read on the video.

I am also using 12.4 (12D4e)
Tested on Catalina 10.15.7 (19H114)

What is your MacOS version ?

Maybe you have an Xcode installation issue ?

Steps to reproduce the error:
Create new Xcode project
Open Main.storyboard
Drag datepicker from the "+"
Run project
tap over the datepicker and scroll to 1996

I cannot reproduce the error following the steps here.
Do you know what is needed?
Hi,

Thanks for the attempt, I had created a video, maybe I am missing something?
Here is the video:

youtu.be/hjskPTB0Ok8

I am using: Version 12.4 (12D4e)
I tried and could not reproduce the crash.

I created a project for iOS (not multiplatform)
UIKit
Storyboard

I tested with 2 date pickers style:
  • on automatic

  • one as wheels

Mode is set to Date

Xcode 12.4
Tested on simulator iPhone 11 ProMax 14.4.
I scrolled to 1996.

No crash.

Could you describe your exact set up ?
Accepted Answer
I looked at video and did the test with the same DatePicker configuration.

No crash.

I tested with 12Pro simulator. No crash.

Could you post the complete crash log, it is not possible to read on the video.

I am also using 12.4 (12D4e)
Tested on Catalina 10.15.7 (19H114)

What is your MacOS version ?

Maybe you have an Xcode installation issue ?
Used OS version: Big sur 11.2
Here is the log:

2021-02-05 12:06:31.717666+0200 test2[50111:1553156] * Assertion failure in -[UIDatePickerCalendarDaySet daysForMonth:includingOverlapDays:], UIDatePickerCalendarDaySet.m:132

2021-02-05 12:06:31.768670+0200 test2[50111:1553156]
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid calculation: number of calculated days is not dividable by the number of days in a week.'
  • First throw call stack:

(

0   CoreFoundation                      0x00007fff20421af6 _exceptionPreprocess + 242

1   libobjc.A.dylib                     0x00007fff20177e78 objc
exceptionthrow + 48

2   CoreFoundation                      0x00007fff2042191f +[NSException raise:format:] + 0

3   Foundation                          0x00007fff2077156a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191

4   UIKitCore                           0x00007fff24bff44b -[
UIDatePickerCalendarDaySet daysForMonth:includingOverlapDays:] + 1338

5   UIKitCore                           0x00007fff241b37e3 -[UIDatePickerCalendarViewDataSourceController prepareDataSourceWithScrollPositionIfNecessary:] + 493

6   UIKitCore                           0x00007fff242a2223
112-[UIDatePickerCalendarDateView setVisibleMonth:animated:updateDataSource:updateCollectionView:notifyDelegate:]blockinvoke + 60

7   UIKitCore                           0x00007fff242a2275 -[
UIDatePickerCalendarDateView performIgnoringScrollCallbacks:] + 59

8   UIKitCore                           0x00007fff242a2184 -[
UIDatePickerCalendarDateView setVisibleMonth:animated:updateDataSource:updateCollectionView:notifyDelegate:] + 192

9   UIKitCore                           0x00007fff242a1afb -[
UIDatePickerCalendarDateView setSelectedDate:animated:updateVisibleMonth:updateCollectionView:notifyDelegate:] + 282

10  UIKitCore                           0x00007fff242a19db -[
UIDatePickerCalendarDateView setSelectedDate:animated:] + 40

11  UIKitCore                           0x00007fff23b4b8a3 -[UIDatePickerCalendarView updateSelectedDay:time:animated:notify:] + 936

12  UIKitCore                           0x00007fff23b4b9d8 -[UIDatePickerCalendarView updateSelectedDay:animated:notify:] + 106

13  UIKitCore                           0x00007fff23b4bbe2 -[UIDatePickerCalendarView updateSelectedDayToDayInMonth:animated:notify:] + 351

14  UIKitCore                           0x00007fff23b4c00e -[UIDatePickerCalendarView monthYearSelector:didSelectMonth:] + 60

15  UIKitCore                           0x00007fff24ad2c60 -[
UIDatePickerCalendarMonthYearSelector setSelectedMonth:animated:updatePicker:notifyDelegate:] + 236

16  UIKitCore                           0x00007fff24ad2d91 -[
UIDatePickerCalendarMonthYearSelector didSelectDate:] + 172

17  UIKitCore                           0x00007fff2469d19e -[UIApplication sendAction:to:from:forEvent:] + 83

18  UIKitCore                           0x00007fff23fc6684 -[UIControl sendAction:to:forEvent:] + 223

19  UIKitCore                           0x00007fff23fc69a7 -[UIControl
sendActionsForEvents:withEvent:] + 332

20  UIKitCore                           0x00007fff24615bf9 -[UIDatePickerView pickerView:didSelectRow:inComponent:] + 395

21  UIKitCore                           0x00007fff24621f65 -[UIPickerView
sendSelectionChangedForComponent:notify:] + 103

22  UIKitCore                           0x00007fff2461c2bd -[UIPickerTableView scrollingFinished] + 184

23  UIKitCore                           0x00007fff2461c4c0 -[UIPickerTableView scrollViewDidEndDecelerating:] + 27

24  UIKitCore                           0x00007fff24b8628a -[UIScrollView
scrollViewDidEndDeceleratingForDelegate] + 148

25  UIKitCore                           0x00007fff24b7ffc1 -[UIScrollView stopScrollDecelerationNotify:] + 560

26  UIKitCore                           0x00007fff24b80227 -[UIScrollView
stopScrollingNotify:pin:tramplingDragFlags:] + 508

27  UIKitCore                           0x00007fff248bfe42 -[UITableView stopScrollingNotify:pin:] + 42

28  UIKitCore                           0x00007fff24b75526 -[UIScrollView
smoothScrollWithUpdateTime:] + 3278

29  UIKitCore                           0x00007fff24b75794 -[UIScrollView smoothScrollDisplayLink:] + 395

30  QuartzCore                          0x00007fff279c32b9
ZN2CA7Display11DisplayLink14dispatchitemsEyyy + 755

31  QuartzCore                          0x00007fff27aa8dbc
ZL22displaytimercallbackP12_CFMachPortPvlS1 + 639

32  CoreFoundation                      0x00007fff2035d9d8 _CFMachPortPerform + 157

33  CoreFoundation                      0x00007fff20390c82 CFRUNLOOP
ISCALLINGOUTTOASOURCE1PERFORMFUNCTION + 41

34  CoreFoundation                      0x00007fff20390023
CFRunLoopDoSource1 + 614

35  CoreFoundation                      0x00007fff2038a4f2
CFRunLoopRun + 2353

36  CoreFoundation                      0x00007fff203896d6 CFRunLoopRunSpecific + 567

37  GraphicsServices                    0x00007fff2c257db3 GSEventRunModal + 139

38  UIKitCore                           0x00007fff24696cf7 -[UIApplication
run] + 912

39  UIKitCore                           0x00007fff2469bba8 UIApplicationMain + 101

40  libswiftUIKit.dylib                 0x00007fff551885f2 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 98

41  test2                               0x00000001093ccaea $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 122

42  test2                               0x00000001093cca5e $s5test211AppDelegateC5$mainyyFZ + 46

43  test2                               0x00000001093ccb39 main + 41

44  libdyld.dylib                       0x00007fff2025a3e9 start + 1

45  ???                                 0x0000000000000001 0x0 + 1

)

libc++abi.dylib: terminating with uncaught exception of type NSException

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid calculation: number of calculated days is not dividable by the number of days in a week.'

terminating with uncaught exception of type NSException

CoreSimulator 732.18.6 - Device: iPhone 12 Pro (52D9022C-204E-4C1E-9596-1BFA46B08979) - Runtime: iOS 14.4 (18D46) - DeviceType: iPhone 12 Pro

(lldb) 
I was able to get a real device to test.
Seems to be working fine on it.
Maybe as pointed out by Claude31 it's either Xcode installation issue or something with the OS of the simulators.

Thanks for everyone's time.
I have encountered the same issue, 200++ crashes on the app I developed, hope Apple can provide a solution for that.

Error message from Crashlytics
Fatal Exception: NSInternalInconsistencyException
Invalid calculation: number of calculated days is not dividable by the number of days in a week.


The same here. Crashlytic reports this crash for 14.4.0 (18D52) on iPhone 7 Plus, so it's a real device, in a production app.
I'm seeing these crashes also, but only for Beirut (!). You can recreate by setting the device's time zone to Beirut, while leaving the current Region to United States (or any region other than Lebanon).

Force current Region to Lebanon in Edit Scheme -> Options -> App Region and it doesn't crash. But setting the picker's locale to en_LB (Lebanon) doesn't help.

There must be something specific about the mismatch of time zone and region for Lebanon but I haven't found it. A (poor) workaround might be to identify the mismatch and switch the picker.preferredDatePickerStyle to .wheel in that case only.
I agree with @3no, my timezone was set to Beirut, and I was facing crashes with date/time pickers. When changing it to Boston, US for example, it worked.
Maybe Beirut will be deleted from the map soon, lol!
@3no @eliaszaghrini.
did you find any solution to this?
I came not as a dev, but I had this error simply entering time in Calendar or Alarm. Thanks @3no, your tip resolved the issue for me too!
Met the same problem on iPhone 12 Pro simulator.
MacOS 11.2.3
iOS 14.4
Kyiv TimeZone

It is not reproduced on real iPhone X with iOS 14.4.2
Every one of my users who experienced this crash is in Lebanon/Beirut and is on iOS 14.4 and up
I have the same crash report showing up in crashlytics. iPhone XS iOS 14.4.2
Is this still not fixed by apple?


Datepicker iOS 14 crashes on completely empty project
 
 
Q