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

NSInternalInconsistencyException Crash with 2.1.5 #145

Closed
mmdock opened this issue Mar 3, 2021 · 8 comments
Closed

NSInternalInconsistencyException Crash with 2.1.5 #145

mmdock opened this issue Mar 3, 2021 · 8 comments

Comments

@mmdock
Copy link

mmdock commented Mar 3, 2021

Fatal Exception: NSInternalInconsistencyException
attempt to delete item 49 from section 0 which only contains 0 items before the update

Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x2356cf180 __exceptionPreprocess
1 libobjc.A.dylib 0x2348a79f8 objc_exception_throw
2 CoreFoundation 0x2355e888c +[_CFXNotificationTokenRegistration keyCallbacks]
3 Foundation 0x2360acb38 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4 UIKitCore 0x2619a9084 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:]
5 UIKitCore 0x2619b21b8 -[UICollectionView _endUpdatesWithInvalidationContext:tentativelyForReordering:animator:]
6 UIKitCore 0x2619b24ec -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:]
7 UIKitCore 0x2619b234c -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:]
8 UIKitCore 0x2619b22d0 -[UICollectionView _performBatchUpdates:completion:invalidationContext:]
9 UIKitCore 0x2619b220c -[UICollectionView performBatchUpdates:completion:]
10 GiphyUISDK 0x10253155c hidden#3655
11 GiphyUISDK 0x102512430 hidden#2318
12 GiphyUISDK 0x102512450 hidden#2319
13 UIKitCore 0x26252b8f0 +[UIView(Animation) performWithoutAnimation:]
14 GiphyUISDK 0x102531314 hidden#3654
15 GiphyUISDK 0x102512430 hidden#2318
16 GiphyUISDK 0x102512450 hidden#2319
17 libdispatch.dylib 0x23510d7d4 _dispatch_client_callout
18 libdispatch.dylib 0x2350bbcec _dispatch_async_and_wait_invoke
19 libdispatch.dylib 0x23510d7d4 _dispatch_client_callout
20 libdispatch.dylib 0x2350bb008 _dispatch_main_queue_callback_4CF$VARIANT$mp
21 CoreFoundation 0x235660b20 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
22 CoreFoundation 0x23565ba58 __CFRunLoopRun
23 CoreFoundation 0x23565afb4 CFRunLoopRunSpecific
24 GraphicsServices 0x23785c79c GSEventRunModal
25 UIKitCore 0x2620a1c38 UIApplicationMain
26 Her 0x100c6a8f8 main + 11 (main.swift:11)
27 libdyld.dylib 0x23511e8e0 start

Also, not sure why everything with GiphyUISDK is coming up "_hidden#" on the stack traces.

@cgmaier
Copy link
Contributor

cgmaier commented Mar 3, 2021

hey @mmdock thanks for flagging this

some more helpful details that would be good to know are:

  • are there any specific repro steps?
  • can we pinpoint device types / iOS versions where this is happening?
  • do you have data around the frequency of the crash?
  • are you using a GiphyGridController or GiphyViewController based solution?

@mmdock
Copy link
Author

mmdock commented Mar 3, 2021

@cgmaier Repro steps: None at this time. I just rolled out giphy updated to 2.1.5 in my latest app release on Monday and I noticed that this was a new issue. Since Monday around 1pm PST this has gotten about only 10 crashes. I have yet to try and repro personally.

Devices / OS:
Looks like entirely on iOS 12 at this time

This is the entirety of my giphy implementation 😆

extension MediaPickerManager: GiphyDelegate {
    func showGiphy(from viewController: UIViewController){
        let giphy = GiphyViewController()
        GiphyViewController.trayHeightMultiplier = 0.6
        giphy.setAPIKey(Application.settings.giphySDKKey)
        giphy.theme = GPHTheme(type: .light)
        giphy.mediaTypeConfig = [.gifs, .recents, .stickers, .emoji, .text]
        giphy.showConfirmationScreen = false
        giphy.shouldLocalizeSearch = true
        giphy.rating = .ratedR
        giphy.delegate = self
        giphy.dimBackground = true
        giphy.modalPresentationStyle = .overCurrentContext
        ui{ viewController.present(giphy, animated: true, completion: nil) }
    }
   
    // MARK: - GiphyDelegate
    func didSelectMedia(giphyViewController: GiphyViewController, media: GPHMedia) {
        giphyViewController.dismiss(animated: true, completion: nil)
        guard let urlString = media.mobilePriorityURL(), let url = URL(string: urlString) else {
            giphypickerDelegate?.didFinishPicking(gif: nil)
            return
        }
        let gif = MessageGif(id: media.id, url: url, ratio: media.aspectRatio)
        giphypickerDelegate?.didFinishPicking(gif: gif)
    }
    
    func didDismiss(controller: GiphyViewController?) {
        giphypickerDelegate?.didFinishPicking(gif: nil)
    }
}

extension GPHMedia {
    
    ///Will receive the most mobile friendly url that exists for this media
    public func mobilePriorityURL() -> String? {
        //First checks for the renditions of webp, then gif.  find first successful url.
        //This is a slight change in behavior compared to before, in that our in-house picker used to always pick the original size only. Now we are prioritizing mobile friendly sizes.  Should improve feed experience, particularly for users with poorer connections.
        return self.url(renditions: [.fixedHeight, .fixedWidth, .downsized, .downsizedMedium, .downsizedLarge, .original], fileTypes: [.webp, .gif])
    }
    
    ///Will receive the first valid rendition found of most preferred type
    public func url(renditions: [GPHRenditionType], fileTypes: [GPHFileExtension]) -> String?{
        
        for type in fileTypes{
            for rendition in renditions{
                if let url = self.url(rendition: rendition, fileType: type){
                    return url
                }
            }
        }
        
        return nil
        
    }
}

@cgmaier
Copy link
Contributor

cgmaier commented Mar 5, 2021

nice integration! we'll take a look. please keep us posted around any additional insights @mmdock

@cgmaier
Copy link
Contributor

cgmaier commented Mar 18, 2021

pushed a new version with a hopeful fix for this.
https://github.com/Giphy/giphy-ios-sdk/releases/tag/v2.1.6

thanks @mmdock !

@mmdock
Copy link
Author

mmdock commented Apr 26, 2021

@cgmaier hey! just saw this mention. Will include the giphy update in our May 3rd release and will let you know shortly after if this is resolved

@cgmaier
Copy link
Contributor

cgmaier commented May 7, 2021

hey @mmdock thanks! do you have any update?

@mmdock
Copy link
Author

mmdock commented May 14, 2021

@cgmaier still visible in my crashlytics logging for our app version that included giphy 2.1.6

@mmdock
Copy link
Author

mmdock commented May 14, 2021

it does looks like the crash frequency is down though
Screen Shot 2021-05-14 at 11 56 02 AM

@cgmaier cgmaier closed this as completed Nov 2, 2022
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

2 participants