Giter Site home page Giter Site logo

Comments (2)

shaps80 avatar shaps80 commented on June 11, 2024

This doesn't really make sense. The whole point of calling performBatchUpdates for every single update is to ensure it enqueues those correctly. So it shouldn't be possible to NOT have index-0. That being said I do remember reading somewhere that the call to performBatchUpdates is sync while the internal execution is async. So it'll return immediately but potentially execute later. I believe this is to ensure you can call this quite rapidly without issue.

The most common cause of issues here is usually the data being out of sick. Are you updating the model inside the performBatchUpdates as well, you should be?

from composed.

JosephDuffy avatar JosephDuffy commented on June 11, 2024

The most common cause of issues here is usually the data being out of sick. Are you updating the model inside the performBatchUpdates as well, you should be?

Moving to the closure-based design is aimed to ensure that the models are updated inside performBatchUpdates (Composed is currently not guaranteeing this).


One way this crash seems to happen is when the configuration of a header (possibly cells, I've not tested this yet) triggers an update. This is probably impossible to support without capturing the updates closure and I think should be classed as a misuse of the API (note that I wrote part of this 😬).

The workaround I've found (after a few separate debugging sessions) is to invalidate all if this scenario is detected:

  • performBatchUpdates has been called on the collection view
  • All updates have been applied to the collection view

After the updates have been applied the collection will layout, dequeuing views as necessary. If any of these views then trigger an update it will enter CollectionCoordinator.mapping(_:willPerformBatchUpdates:) again, so the logs make sense now.

I've added a long print statement when this happens so consumers can debug this a little easier. Invalidating everything fixes the crash so I think this is a good compromise?

At first I thought this might work because collection view apparently supports nested batch updates:

image

But I would guess their logic is along the lines of:

  • Call updates
  • Dequeue views
  • Commit changes
  • async wait for animations
  • Call completion

Because the crash is essentially:

  • Call updates
    • updates inserts 0,0
  • Dequeue views
    • Dequeuing deletes 0,0
  • Crash because 0,0 doesn't exist

from composed.

Related Issues (10)

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.