Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar crashes when minimumDate & maximumDate is set #575

Closed
snamrata007 opened this issue Feb 2, 2017 · 17 comments
Closed

Calendar crashes when minimumDate & maximumDate is set #575

snamrata007 opened this issue Feb 2, 2017 · 17 comments

Comments

@snamrata007
Copy link

snamrata007 commented Feb 2, 2017

I am using xcode 8.2 and ios 10.1 .

*** Assertion failure in -[UICollectionViewData validateLayoutInRect:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/UICollectionViewData.m:433
2017-02-02 12:01:42.310 DemoCalendar[788:16847] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0xc000000000000716> {length = 2, path = 7 - 0}'

@krezzoid
Copy link

krezzoid commented Feb 3, 2017

seems like this issue appears only if minimumDate is equal to current date:

    public func minimumDate(for calendar: FSCalendar) -> Date {
        return Date() // crash!
    }
    
    public func maximumDate(for calendar: FSCalendar) -> Date {
        return Date().addDays(365)
    }

@nooralibutt
Copy link

@krezzoid I tried your solution. Somehow it worked on some random dates but If I set minimum date two days earlier than current date it still crashes and even 3 days or 4 days. but if I try 7 days before current day it works.

@HungryFour
Copy link

复现了这个bug.
2017-02-13 10:32:13.672 FitFile[2198:56208] *** Assertion failure in -[UICollectionViewData validateLayoutInRect:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/UICollectionViewData.m:433
在iPhone上,设置minimumDate和maximumDate都没有问题
但是iPad上,设置这两个必现crashes.

@WenchaoD
Copy link
Owner

Can't reproduce this in demo project. Can anyone provide a demo with latest code in master?

@markj
Copy link

markj commented Feb 13, 2017

I have this problem too. Although in my case the minimum date is set to 3 months ago..
If I set the maximum date to today, it crashes. Changing that to Date.distantFuture it's fine.

@markj
Copy link

markj commented Feb 13, 2017

I still get this problem with the latest master (with #585 merged in).

Strangely the issue occurs when running the iPhone only app on an iPad but not on an iPhone.

@krezzoid
Copy link

Strangely the issue occurs when running the iPhone only app on an iPad but not on an iPhone.

for me this always happens with iPhone only app running on iPhone :) latest version of Xcode & simulator

@markj
Copy link

markj commented Feb 13, 2017

I've updated the swift demo app with code similar to what I'm using.
Strangely it doesn't crash in the situation I have when running against iOS 10 but it does show the same problem for iOS 9 running on the iPhone 4s.

https://github.com/markj/FSCalendar/commits/master

To reproduce,

  1. Start iPhone 4s sim (9.3)
  2. Launch swift demo app
  3. Select FSCalendarScope

Boom:

2017-02-13 10:06:51.771 FSCalendarSwiftExample[2951:2320699] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0x7a0cff00> {length = 2, path = 4 - 0}'
*** First throw call stack:
(
	0   CoreFoundation                      0x00cbd494 __exceptionPreprocess + 180
	1   libobjc.A.dylib                     0x0077ee02 objc_exception_throw + 50
	2   CoreFoundation                      0x00cbd32a +[NSException raise:format:arguments:] + 138
	3   Foundation                          0x003fa322 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 118
	4   UIKit                               0x02353e55 __45-[UICollectionViewData validateLayoutInRect:]_block_invoke + 1116
	5   UIKit                               0x02352dfb -[UICollectionViewData validateLayoutInRect:] + 1329
	6   UIKit                               0x02355b79 -[UICollectionViewData layoutAttributesForElementsInRect:] + 132
	7   UIKit                               0x022ef237 -[UICollectionView _updateVisibleCellsNow:] + 605
	8   UIKit                               0x022f57df -[UICollectionView layoutSubviews] + 254
	9   UIKit                               0x01a333d4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
	10  libobjc.A.dylib                     0x00793059 -[NSObject performSelector:withObject:] + 70
	11  QuartzCore                          0x01829096 -[CALayer layoutSublayers] + 144
	12  QuartzCore                          0x0181c8b6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
	13  QuartzCore                          0x0181c71a _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
	14  QuartzCore                          0x0180eee7 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
	15  QuartzCore                          0x01843847 _ZN2CA11Transaction6commitEv + 561
	16  QuartzCore                          0x018450b8 _ZN2CA11Transaction17flush_transactionEv + 50
	17  UIKit                               0x01994f55 _afterCACommitHandler + 197
	18  CoreFoundation                      0x00bcf75e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
	19  CoreFoundation                      0x00bcf6be __CFRunLoopDoObservers + 398
	20  CoreFoundation                      0x00bc503c __CFRunLoopRun + 1340
	21  CoreFoundation                      0x00bc4846 CFRunLoopRunSpecific + 470
	22  CoreFoundation                      0x00bc465b CFRunLoopRunInMode + 123
	23  GraphicsServices                    0x05d2a664 GSEventRunModal + 192
	24  GraphicsServices                    0x05d2a4a1 GSEventRun + 104
	25  UIKit                               0x01962eb9 UIApplicationMain + 160
	26  FSCalendarSwiftExample              0x00110cf1 main + 145
	27  libdyld.dylib                       0x002a5a25 start + 1
)

@enfoiro
Copy link

enfoiro commented Feb 13, 2017

We started to have this issue when we upgraded from 2.3.0 -> 2.6.0, we tried with the latest release as well, still the same issue, so we downgraded back to 2.3.0, happening when we have a date selected, plus a min and max date set, can happen when loading the view, or scrolling to change the month.
Strange thing is that I think it's happening only when having a selected date in february, maybe it has to do with the fact that they are less days in this month.
When we have a selected date in a different month, we can't reproduce the bug.

🤞 Hope it'll help.

@WenchaoD
Copy link
Owner

@markj I reproduced your issue from your forked branch. But this is fixed after I override the FSCalendar folder from development branch. Would you guys like to try again and provide some feedback?

@backofthecup
Copy link

backofthecup commented Feb 15, 2017

Using the development branch worked for me. Thanks! When do you think this might be pushed to the CocoaPod repository?

@markj
Copy link

markj commented Feb 15, 2017

Oh darn it! You are right. Sorry, I didn't see the dev branch - just master was newer than the tag..

I no longer see the issue with the development branch either..

Great stuff! Thanks.

@backofthecup
Copy link

There's definitely an issue when the selectDate = minimumDate. The selected date that shows on the calendar is the day before what was specified. I've attached a small project showing this.

CalendarTest.zip

@WenchaoD
Copy link
Owner

@backofthecup Pushed to Cocoapods. Please try 2.7.2, along with the fix of your last issue.

image

@backofthecup
Copy link

Awesome! Got the update. Everything looks good. Thanks for getting this done, we have a production release next week and we really needed this working. If you're ever in Austin, TX the drinks are on me!

@shilpashreemayigaiah
Copy link

Still app is crashing when minimum or maximum date is current date...these both dates am getting from webservice so how can i do this one?

@FirstGitHubAccount
Copy link

Still this crash happens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants