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

【Crash】Invalid batch updates detected #257

Open
FoneG opened this issue Oct 3, 2024 · 8 comments
Open

【Crash】Invalid batch updates detected #257

FoneG opened this issue Oct 3, 2024 · 8 comments
Labels

Comments

@FoneG
Copy link

FoneG commented Oct 3, 2024

🐛 Bug Report

I am reaching out to report a bug I've encountered after upgrading the Giphy SDK from version 2.1.22 to 2.2.9. This issue has been present since the initial integration, but after the recent upgrade, I’ve noticed a significant increase in its occurrence, particularly on iOS 17 and 18 devices.

Crash Details:

Fatal Exception: NSInternalInconsistencyException
Invalid batch updates detected: the number of sections and/or items returned by the data source before and after performing the batch updates are inconsistent with the updates. 
Data source before updates = { 1 section with item counts: [25] } 
Data source after updates = { 1 section with item counts: [25] } 
Updates = [ Insert item (0 - 0), Insert item (0 - 1), Insert item (0 - 2), ... , Insert item (0 - 24) ]
Collection view: <UICollectionView: 0x1088c1000; frame = (-196.5 -244.333; 393 488.667); ... ; layout: <GiphyUISDK.GPHWaterfallLayout: 0x14730c860>; dataSource: <GiphyUISDK.GiphyGridController: 0x108e1ca00>>

Additional Context:
The SDK is integrated using Objective-C.

Although I do not explicitly call addChildViewController:, I persist the GiphyGridController objects via properties. I retain two instances of GiphyGridController due to the design of my app. I believe this should not affect how UICollectionView updates its data, but I wanted to provide this context for clarity.

Below is my initialization code for the GiphyGridController:



- (GiphyGridController *)tabGIFSearchVC
{
    if (_tabGIFSearchVC == nil) {
        _tabGIFSearchVC = [[GiphyGridController alloc] init];
        _tabGIFSearchVC.direction = UICollectionViewScrollDirectionVertical;

        GPHTheme *theme = [[GPHTheme alloc] init];
        theme.type = GPHThemeTypeDark;
        _tabGIFSearchVC.theme = theme;

        _tabGIFSearchVC.rating = GPHRatingTypeRatedG;
        _tabGIFSearchVC.cellPadding = 10.0;
        [_tabGIFSearchVC setNumberOfTracks:[self numberOfTracks]];
        _tabGIFSearchVC.renditionType = GPHRenditionTypeFixedHeightDownsampled;
        _tabGIFSearchVC.delegate = self;
        _tabGIFSearchVC.fixedSizeCells = YES;
        _tabGIFSearchVC.view.backgroundColor = UIColor.is_dark_mode_complexBackgroundColor1;
    }

    return _tabGIFSearchVC;
}

{
    self.tabGIFSearchVC.view.hidden = NO;
    if ([self.searchWord isNSStringAndNotEmpty]) {
        GPHMediaType mediaType = GPHMediaTypeSticker;
        if (_type == ISGIFSourceTypeGIF) {
            mediaType = GPHMediaTypeGif;
        }else if (_type == ISGIFSourceTypeText){
            mediaType = GPHMediaTypeText;
        }
        GPHContent *content = [GPHContent searchWithQuery:self.searchWord mediaType:mediaType language:GPHLanguageTypeEnglish includeDynamicResults:YES];
        self.tabGIFSearchVC.content = content;
    }else{
        if (self.type == GPHMediaTypeGif) {
            self.tabGIFSearchVC.content = [GPHContent trendingGifs];
        }else if (self.type == GPHMediaTypeSticker){
            self.tabGIFSearchVC.content = [GPHContent trendingStickers];
        }else{
            self.tabGIFSearchVC.content = [GPHContent trendingText];
        }
    }
    [self.tabGIFSearchVC update];
}

I would greatly appreciate any assistance or insights that could help resolve this issue, as it is currently affecting the stability of my application.
Thank you in advance for your support, and I look forward to your response.

@FoneG FoneG added the bug Something isn't working label Oct 3, 2024
@FoneG FoneG changed the title Fatal Exception: NSInternalInconsistencyException 【Crash】Invalid batch updates detected Oct 9, 2024
@ALexanderLonsky
Copy link
Collaborator

Hey @FoneG,
Are you experiencing this issue in v2.2.11?

@FoneG
Copy link
Author

FoneG commented Oct 11, 2024

Unfortunately, I was unable to reproduce this error in any version, so I'm not sure if it will be fixed after the upgrade. Can you check to see if you have already committed the code for this issue?

@ALexanderLonsky
Copy link
Collaborator

We were able to reproduce and fix this issue.
However, using the latest version, I haven’t been able to reproduce the issue you're experiencing.

@FoneG
Copy link
Author

FoneG commented Oct 11, 2024

I encountered this issue in version 2.2.9. Is it resolved in the version after that? Can I fix my problem by upgrading to v2.2.11?

@FoneG
Copy link
Author

FoneG commented Oct 14, 2024

Hey @ALexanderLonsky, the crash issue is still persisting. Could you provide some more clarity or a definitive solution when possible? Appreciate your help!

I encountered this issue in version 2.2.9. Is it resolved in the version after that? Can I fix my problem by upgrading to v2.2.11?

@ALexanderLonsky
Copy link
Collaborator

It seems to be a different issue, and we haven’t been able to reproduce it yet. We’ll keep trying and work on resolving it. We’ll update you as we make progress.

@ALexanderLonsky
Copy link
Collaborator

Good news. We've successfully reproduced the crash, and the fix is on its way.
It will be released later this week.

@ALexanderLonsky
Copy link
Collaborator

@FoneG
A new version with the fix has been released: v2.2.13

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

No branches or pull requests

2 participants