patchthecode / JTAppleCalendar

The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable
https://patchthecode.com
MIT License
7.57k stars 811 forks source link

Only iOS 17 Crash - JTACMonthLayout - setupDataFromDelegate #1385

Open HalitGumus opened 1 year ago

HalitGumus commented 1 year ago

Hi, First of all, I am using the latest version of JTAppleCalendar (8.0.2).It was crashing in the previous (8.0.1) version

Description

Only iOS 17 users experience the error in the screenshot below. It doesn't always crash, it crashes every 2-3 attempts.

Screenshot 2023-10-02 at 12 51 43 PM

Firebase Crashlytics

Crashed: com.apple.main-thread 0 JTAppleCalendar 0x26ba8 $s15JTAppleCalendar15JTACMonthLayoutC21setupDataFromDelegateyyF + 1020 1 JTAppleCalendar 0x265fc $s15JTAppleCalendar15JTACMonthLayoutC7prepareyyF + 396 2 JTAppleCalendar 0x2679c $s15JTAppleCalendar15JTACMonthLayoutC7prepareyyFTo + 28 3 UIKitCore 0x1309d4 -[UICollectionViewData _prepareToLoadData] + 100 4 UIKitCore 0x12db5c -[UICollectionViewData validateLayoutInRect:] + 100 5 UIKitCore 0x7a84c -[UICollectionView layoutSubviews] + 220 6 JTAppleCalendar 0x22584 $s15JTAppleCalendar13JTACMonthViewC14layoutSubviewsyyF + 48 7 JTAppleCalendar 0x22698 $s15JTAppleCalendar13JTACMonthViewC14layoutSubviewsyyFTo + 28 8 UIKitCore 0x331d8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1528 9 QuartzCore 0x67888 CA::Layer::layout_if_needed(CA::Transaction) + 500 10 QuartzCore 0x67410 CA::Layer::layout_and_display_if_needed(CA::Transaction) + 144 11 QuartzCore 0x6d94c CA::Context::commit_transaction(CA::Transaction, double, double) + 464 12 QuartzCore 0x66c3c CA::Transaction::commit() + 648 13 QuartzCore 0x668e4 CA::Transaction::flush_as_runloop_observer(bool) + 88 14 CoreFoundation 0x361dc CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 36 15 CoreFoundation 0x34be4 CFRunLoopDoObservers + 548 16 CoreFoundation 0x34300 CFRunLoopRun + 1028 17 CoreFoundation 0x33e18 CFRunLoopRunSpecific + 608 18 GraphicsServices 0x35ec GSEventRunModal + 164 19 UIKitCore 0x22f350 -[UIApplication _run] + 888 20 UIKitCore 0x22e98c UIApplicationMain + 340 21 Appname 0x7118 main + 21 (AppDelegate.swift:21) 22 ??? 0x1d03e3d44 (Missing) Screenshot 2023-10-02 at 1 01 59 PM

patchthecode commented 1 year ago

the latest version is 8.0.5 maybe that might be reason why?

patchthecode commented 1 year ago

I will update the New issue version to 8.0.5 so this confusion wont happen again

HalitGumus commented 1 year ago

When I check again, I was already using version 8.0.5. There is a bug in this version

ranjeetpisal commented 1 year ago

we have checked again I am on version 8.0.5. still issue is there

imdbest25 commented 1 year ago

I am also facing same issue with version 8.0.5 version of library installed. And apple is not going to accept my build for further release until the issue is fixed. Please comment any solution if you have

HalitGumus commented 1 year ago

This crash seems to occur when the start and end dates are the same.

func configureCalendar(_ calendar: JTACMonthView) -> ConfigurationParameters {

        guard let startDate = self.startDate, let endDate = self.endDate else {
            return ConfigurationParameters(startDate: Date(), endDate: Date(), numberOfRows: 5, generateOutDates: .tillEndOfRow, firstDayOfWeek: .monday)

        }
        return ConfigurationParameters(startDate: startDate, endDate: endDate, numberOfRows: 5, generateOutDates: .tillEndOfRow, firstDayOfWeek: .monday)
    }
endDate: Date()

When I changed this code as follows, the problem was solved for me.

endDate: Date().addingTimeInterval(1)
patchthecode commented 1 year ago

@HalitGumus thank you!! If this is the issue, then the fix is extremely simple.

I'll respond back here in a bit

patchthecode commented 1 year ago

@HalitGumus i made a code change to master branch. If you are using Swift Package manager, set it to use master branch instead of 8.0.5 and let me know if the issue persists.

imdbest25 commented 1 year ago

Thank you @HalitGumus @patchthecode for quick responses. The solution worked for me.

HalitGumus commented 1 year ago

@patchthecode I am using pod, and when I updated it with the relevant commit as below, the same crash occurred. I'll try again when the version(8.0.6) comes out.

pod 'JTAppleCalendar', :git => 'https://github.com/patchthecode/JTAppleCalendar', :commit => 'abf4cfccc62ef75a070d0dded0fd823d5a86f72a'

patchthecode commented 1 year ago

@HalitGumus it seems like youre getting crashes consistently which is good.

Any chance you can prove a dry basic app with the crash (remove all company code) The only code that's necessary is the setting up of the calendar etc. You dont even have to design the cells, just create a clean app with the setup.

The reason why I'm asking is because there are many parts it can fail. example

  1. How is it setup in code? What does the code there look like? Or, is it on a Nib? or is it on a Story board? whats the settings there?
  2. Are you loading anything on viewDidLoad?
  3. Are loading up dates etc for multi-selection ? etc etc etc

Many failure points. That last commit should have stopped the crash. I also added an Assert in there as a safety. The assert crashes in development mode and gives you a message on whats wrong. But if its still crashing, then I will need some sort of code to recreate this. Everything is working fine on my sample app attached to this github repository.

Also i'm available all day today on discord chat app. So let me me know if you can link up.