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

JTACMonthLayout Crash #1217

Open
cesariel opened this issue Feb 4, 2020 · 8 comments
Open

JTACMonthLayout Crash #1217

cesariel opened this issue Feb 4, 2020 · 8 comments

Comments

@cesariel
Copy link

cesariel commented Feb 4, 2020

(Required) Version Number: 8.0.3

Description

#0 0x000000010483853c in JTACMonthLayout.setupDataFromDelegate() at ~/Pods/JTAppleCalendar/Sources/JTAppleCalendar/JTACMonthLayout.swift:168
JTAppleCalendar was compiled with optimization - stepping may behave oddly; variables may not be available.

Line 168:
strictBoundaryRulesShouldApply = thereAreHeaders || delegate._cachedConfiguration.hasStrictBoundaries

Steps To Reproduce

func setupCalendarView() {
        calendarView.minimumLineSpacing = 0
        calendarView.minimumInteritemSpacing = 0        
        calendarView.visibleDates { (visibleDates) in
            self.setupViewsOfCalendar(from: visibleDates)
        }

        if(self.appoDates.count > 0) {
            self.calendarView.selectDates(self.appoDates)
        }
        self.formatter.dateFormat = "yyyy MM dd"
        self.calendarView.selectDates([formatter.date(from: getTodayDate())!])
    }
    
    func setupViewsOfCalendar(from visibleDates: DateSegmentInfo){    
        let date = visibleDates.monthDates.first!.date
        formatter.dateFormat = "yyyy"
        year.text = formatter.string(from: date)        
        formatter.dateFormat = "MMMM"
        month.text = formatter.string(from: date).capitalized
    }

Expected Behavior

Additional Context

@patchthecode
Copy link
Owner

is it possible you can provide a sample app with this crash?

@umarchohan
Copy link

I am also getting the same crash.
Any luck with solving that @cesariel ?

@patchthecode
Copy link
Owner

@umarchohan
is it possible you can create a sample app (a barebones minimal app with no company code inside it) that recreates this issue?

@umarchohan
Copy link

@patchthecode
you can check with these settings as per @cesariel

func setupCalendarView() {
        calendarView.minimumLineSpacing = 0
        calendarView.minimumInteritemSpacing = 0        
        calendarView.visibleDates { (visibleDates) in
            self.setupViewsOfCalendar(from: visibleDates)
        }

        if(self.appoDates.count > 0) {
            self.calendarView.selectDates(self.appoDates)
        }
        self.formatter.dateFormat = "yyyy MM dd"
        self.calendarView.selectDates([formatter.date(from: getTodayDate())!])
    }
    
    func setupViewsOfCalendar(from visibleDates: DateSegmentInfo){    
        let date = visibleDates.monthDates.first!.date
        formatter.dateFormat = "yyyy"
        year.text = formatter.string(from: date)        
        formatter.dateFormat = "MMMM"
        month.text = formatter.string(from: date).capitalized
    }

@patchthecode
Copy link
Owner

if you are using the same code.
Can you confirm that it is not crashing at the forced optional values?
I see you force the values
here --> self.calendarView.selectDates([formatter.date(from: getTodayDate())!])
and here -> let date = visibleDates.monthDates.first!.date
using the ! character.

@jvisenti
Copy link
Contributor

jvisenti commented May 11, 2021

I'm encountering this same issue in version 8.0.3.
The crash is caused by this implicitly unwrapped optional in JTACMonthView.swift:115:

// Configuration parameters from the dataSource
var _cachedConfiguration: ConfigurationParameters!

which is used in JTACMonthLayout.Swift:168:

strictBoundaryRulesShouldApply = thereAreHeaders || delegate._cachedConfiguration.hasStrictBoundaries

A nil value for _cachedConfiguration crashes the app. Since this is an internal property, I believe the library should be updated to avoid force unwrapping, and guard or handle nil values rather than crashing.

@patchthecode
Copy link
Owner

this happened in production mode or in development?
And how did it happen?

@jvisenti
Copy link
Contributor

this happened in production mode or in development?
And how did it happen?

Production build. In my comment above I describe why the crash occurred, but since _cachedConfiguration is internal to JTAppleCalendar, I don't know what circumstances could cause it to be nil.

jvisenti added a commit to jvisenti/JTAppleCalendar that referenced this issue May 17, 2021
Dean151 added a commit to Dean151/JTAppleCalendar that referenced this issue Sep 26, 2023
Converted some properties from implicitly unwrapped optionals to address crash in patchthecode#1217
robertcrabtree pushed a commit to TapInspect/JTAppleCalendar_OLD that referenced this issue Jan 25, 2024
robertcrabtree pushed a commit to TapInspect/JTAppleCalendar that referenced this issue Apr 15, 2024
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

4 participants