Git Product home page Git Product logo

Comments (14)

kzaher avatar kzaher commented on June 30, 2024

Hi @avdwerff ,

Could you please try latest 0.9 version?

It would be great if you could get us a self contained example that crashes the app.

from rxdatasources.

TheAdamBorek avatar TheAdamBorek commented on June 30, 2024

Hi guys,
I've just figured the cause of my crash in RxCollectionViewSectionedAnimatedDataSource. I had a similar scenario, that UITableView calls cellForRowAtIndexPath: after calling [UITableView endUpdates] with indexPath which was out of bounds of current datasource.

It seems the reason of the crash is ... iOS9 :(. I've found this stackoverflow issue and I tested my scenario on iOS10. It doesn't crash at all

@avdwerff Try running it on different version of iOS

from rxdatasources.

avdwerff avatar avdwerff commented on June 30, 2024

@TheAdamBorek thanks for the tip, I will try! I figured that it happens when the datasource updates , while the collectionview is still in an animation from a previous update.

from rxdatasources.

avdwerff avatar avdwerff commented on June 30, 2024

@kzaher I will check if I can reproduce the problem in a self contained example, unfortunately I can't share the code from the project, since the client is not allowing it. For now I'm ok with using RxCollectionViewSectionedReloadDataSource and until now the crash does not seem to happen anymore.

from rxdatasources.

kzaher avatar kzaher commented on June 30, 2024

@avdwerff yeah, sure.

If you can create a repro case, that would be great, otherwise I've hit a dead end and not sure what can I do :)

I'm also shipping this code, and I'm sure other people are also, so I would like to understand what was the exact problem you've encountered on iOS 9, and can we do something to solve it in a trivial way.

from rxdatasources.

kzaher avatar kzaher commented on June 30, 2024

@avdwerff oh, yeah, sorry. I haven't seen you've mentioned collection view, and not table view.

I've noticed that collection view has a lot of bugs in partial updates code. You can replicate that easily if you perform collection view animated updates fast. If you perform those same updates slower on the same collection views or with any speed on table views, they will work.

¯_(ツ)_/¯

from rxdatasources.

avdwerff avatar avdwerff commented on June 30, 2024

@kzaher so then we know what the problem is I guess, it was about fast partial animated updates in nested collection views. And indeed the crash did not occur when some network call took longer responsible for updating the main collectionview.

from rxdatasources.

kzaher avatar kzaher commented on June 30, 2024

I've added throttle operator inside RxCollectionViewSectionedAnimatedDataSource. It's a silly solution to this problem, but seems to be working for now.

This will be released with Swift 3.0 version of RxDataSources though.

from rxdatasources.

shams-ahmed avatar shams-ahmed commented on June 30, 2024

Hi, am sure I get the same issue as well as #47:

iOS 10.3
RxDataSources Version: 1.0.3

Crash logs:

2017-04-23 11:04:29.812701+0100 APP[1976:576981] *** Assertion failure in -[APP.NearMeCollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.8.1/UICollectionView.m:5781
2017-04-23 11:04:29.813102+0100 APP[1976:576981] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0.  The number of items contained in an existing section after the update (95) must be equal to the number of items contained in that section before the update (95), plus or minus the number of items inserted or deleted from that section (95 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'
*** First throw call stack:
(0x190a26fe0 0x18f488538 0x190a26eb4 0x1914be720 0x197462060 0x197465b34 0x197465e14 0x197465c74 0x197465bf8 0x196d2e400 0x100df8f58 0x100dea7c0 0x100deab44 0x100c58910 0x100dea248 0x100de9e64 0x100de9fb4 0x100f7eeac 0x100f7f690 0x100ee5678 0x100f84efc 0x100f8544c 0x100fccf00 0x100fee928 0x100feda2c 0x100fef300 0x100fe078c 0x100fed438 0x100fef26c 0x100f8339c 0x100f83b88 0x100f4bb3c 0x100f38138 0x101b7da50 0x101b7da10 0x101b82b78 0x1909d50c8 0x1909d2ce4 0x190902da4 0x19236c074 0x196bbd364 0x1000f9d6c 0x18f91159c)
libc++abi.dylib: terminating with uncaught exception of type NSException
(Recorded stack frame) 

from rxdatasources.

shams-ahmed avatar shams-ahmed commented on June 30, 2024

Going to close ticket, my issue was due to timing of binding my models... long story short do bind to models at the end

from rxdatasources.

mashe avatar mashe commented on June 30, 2024

Hello everyone,

I think I have found the root of the issue. It lays in usage of performBatchUpdates:completion: method. According to Apple Documentation:

If the collection view's layout is not up to date before you call this method, a reload may occur. To avoid problems, you should update your data model inside the updates block or ensure the layout is updated before you call performBatchUpdates:completion:.

while RxCollectionViewSectionedAnimatedDataSource updates data model outside the block, what may lead to inconsistency of layout and crash. And actually does sometimes.

RxCollectionViewSectionedAnimatedDataSource.swift:91

                case .animated:
                    for difference in differences {
                        dataSource.setSections(difference.finalSections)

                        collectionView.performBatchUpdates(difference, animationConfiguration: self.animationConfiguration)
                    }
                case .reload:

from rxdatasources.

kzaher avatar kzaher commented on June 30, 2024

@mashe can you do a pull request?

from rxdatasources.

mashe avatar mashe commented on June 30, 2024

@kzaher gonna make it this week

from rxdatasources.

mashe avatar mashe commented on June 30, 2024

@kzaher here it is

from rxdatasources.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.