Commit graph

516 commits

Author SHA1 Message Date
Tim Oliver
060f920f85 Updated the version numbers in all of the documentation 2026-02-15 17:02:29 +09:00
Tim Oliver
062b2f9f70 Bring Test Coverage back to > 99% (#1654)
Summary:
## Changes in this pull request

It's been a few years since I did an audit of our test suite. The majority of changes to IGListKit since then were adding additional error checking and hardening, so this was relatively straightforward.

### Checklist

- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/main/.github/CONTRIBUTING.md)

Pull Request resolved: https://github.com/instagram/IGListKit/pull/1654

Reviewed By: jurmarcus

Differential Revision: D91551666

Pulled By: TimOliver

fbshipit-source-id: c89c7a45abebb44dbf50b252bfadc9a7c2928683
2026-01-27 21:10:09 -08:00
Tim Oliver
dcda4e75ee Replaced FBReportMustFix with IGFailAssert (#1653)
Summary:
## Changes in this pull request

`FBReportMustFix` isn't recognized by the public version of IGListKit. It is wrapped by `IGFailAssert` to abstract error tracking between the public and private versions, and so this change was causing the GitHub repo to stop compiling.

This diff makes the appropriate change and confirms the unit tests are passing again.

### Checklist

- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/main/.github/CONTRIBUTING.md)

Pull Request resolved: https://github.com/instagram/IGListKit/pull/1653

Test Plan:
Compiling again!

 {F1984942550}

Differential Revision: D91551520

Pulled By: TimOliver

fbshipit-source-id: bdc9f786092853252011c551ce6d214a01445c63
2026-01-27 09:44:57 -08:00
Minqi Ma
358fe894f2 Defensive check for NaN frame values in layout
Summary:
Add a defensive check in `IGListCollectionViewLayout` to prevent `NSInternalInconsistencyException` crashes caused by NaN frame values.

**Problem:**
When UIKit attempts to use these NaN frames, it throws `NSInternalInconsistencyException` because NaN comparisons always return false, breaking layout calculations.

**Solution:**
- Check for NaN values in the frame before setting it on `UICollectionViewLayoutAttributes`
- Log a warning via `FBReportWarning` for visibility and debugging
- Return `nil` (consistent with existing OOB check pattern) to prevent the crash

Reviewed By: dinhvh

Differential Revision: D91268614

fbshipit-source-id: 092d85c4b9ef9d5a84238ab4bc4b21a3d768a928
2026-01-23 12:14:38 -08:00
generatedunixname89002005287564
93829a2a07 Run 'facebook-bad-const-placement-check fbtidy' linter on fbobjc via arc cast
Reviewed By: Daij-Djan

Differential Revision: D90872770

fbshipit-source-id: 7a13ea11c9a8eeac4080e3af712dae51b58cfd86
2026-01-16 16:31:13 -08:00
Maxime Ollivier
7240131cea improve assert details in IGListAdapter+UICollectionView
Summary:
These asserts could be very helpful to debug tricky crashes, but they don't tell us enough about which object/section-controller are returning invalid data. The backtrace itself doesn't have the info.

Lets:
* Add object and section-controller class names, but don't include the entire object description (can be very long)
* Clean up how we print NSIndexPath without the memory address. This can make group-by a lot more useful.

## Examples

Before:
>  IGListAdapter returned NaN height = nan for item at indexPath <<NSIndexPath: 0x90c0bb66134b9c8a> {length = 2, path = 0 - 0}>

After:
> IGListAdapter returned NaN width = nan {indexPath: 0-0, object: IGFooViewerLoadingModel, sectionController:IGFooLoadingSectionController, dataSource: IGFooDataSource}

Before:
> Section controller nil for section 1

After:
> Section controller is nil {indexPath: 1-0, object: IGStoryFooViewModel, sectionController: nil, dataSource: IGFooDataSource}

Differential Revision: D90555737

fbshipit-source-id: 7a993ce667d894fa98d59f2258158bf78e3fa33f
2026-01-13 12:57:29 -08:00
Andrew Cuneo
7dddb0d4c8 Formalize that the IGListAdapterDelegateAnnouncer is main-thread affined
Summary:
Today, the IGListAdapterDelegateAnnouncer is different than most other announcers in IG/FB/etc in that it not thread safe to add and remove listeners.

However, this isn't really enforced, and has lead to people calling add / remove on background threads, which is creating crashes: https://fburl.com/logview/f1x4ytdl

A different way to deal with this problem is to make the IGListAdapterDelegateAnnouncer thread safe (eg D87806041), but the principle there seems to be that this class is only intended to be dealt with on the main threasd.

So, the fix here is to just make sure we call this on the thread and add asserts. using on_main here guarantees that we don't dispatch if we are already on the main thread, so it should be safe to add.

Reviewed By: manicakes

Differential Revision: D88427711

fbshipit-source-id: 41f352495e0238618e4d6efe938bdaed370bb139
2025-12-05 09:55:47 -08:00
Tim Oliver
1cfe0ab4b7 Revert the header import changes (#1647)
Summary:
Another code automation changed the import stylings in some of the IGListKit headers. We've since updated the automation to skip IGListKit in future, so we just need to revert this commit and we should be good to go again!

Pull Request resolved: https://github.com/instagram/IGListKit/pull/1647

Test Plan: As long as the tests pass both internally and externally.

Reviewed By: jurmarcus

Differential Revision: D87851377

Pulled By: TimOliver

fbshipit-source-id: e6f1f98684457be41d9a7e197fb44dc8077bc8f0
2025-11-25 01:01:00 -08:00
generatedunixname89002005287564
7ea03a0cf2 fbsource//fbobjc/:30
Reviewed By: rmaz

Differential Revision: D87420822

fbshipit-source-id: 4d9b44b477268c08f764f40b94c995774274e2e1
2025-11-19 09:42:43 -08:00
Hoa Dinh
d1ddab8e20 Fix EXC_BAD_ACCESS crash in IGListSectionMap.m during IGListAdapter deallocation
Summary:
## Initial Devmate Prompt:
[https://www.internalfb.com/logview/basel\_ios\_crashes/cdf37c300a6041eebafd4aa2c2ed9846](https://www.internalfb.com/logview/basel_ios_crashes/cdf37c300a6041eebafd4aa2c2ed9846)

What's the issue that's causing this FAD?

Can you create a fix for it?
 ---
## LLM-generated Summary:
The changes fix a crash in IGListSectionMap.m that occurs during IGListAdapter deallocation. The issue is caused by accessing a nil or invalid sectionController, which is resolved by adding a nil check before invoking the block. This fix prevents the crash when section controllers are no longer available in the map during cleanup, ensuring a safe and defensive programming approach to handle the race condition during deallocation.
 ---
Session: DEV17393008

Differential Revision: D87261228

fbshipit-source-id: 8c147909b3090d8cf2914da1957bcd5d5b8b2cb4
2025-11-17 13:59:51 -08:00
Tim Oliver
98bd6c6a74 Fix the SPM build errors caused by removal of unprefixed headers (#1644)
Summary:
It looks like D86316341 caused the GitHub unit tests to stop passing since SPM relies on IGListKit and IGListDiffKit being in the same directory so there are no module imports.

This diff adds the same `__has_include` conditional checking so our internal and external module configurations will both work.

Pull Request resolved: https://github.com/instagram/IGListKit/pull/1644

Test Plan:
The external tests are working again. As long as the internal tests also pass, we should be good!

 {F1983488354}

Reviewed By: m3rlin45

Differential Revision: D86943807

Pulled By: TimOliver

fbshipit-source-id: c741acbb1f8425e92834daec720d4be3b3c264da
2025-11-17 00:08:32 -08:00
Kaur Ishnoor
0a0b11bdc8 Fix for MID barcelona_ios_fads/c3fbd3e0c8fe65d943ca7fbe1f493880
Differential Revision: D86603481

fbshipit-source-id: 07adbda059d500a1fc41e0b7182738eeb10818c9
2025-11-10 09:54:17 -08:00
Richard Howell
c38d8f337a use prefixed imports in exported_headers
Summary: Replace unprefixed includes in exported_headers with their prefixed equivalents. This avoids filesystem walking to find headers and makes it possible to resolve the headers via header maps.

Reviewed By: d16r

Differential Revision: D86316341

fbshipit-source-id: c3f5d4c5a8911cec45ccac2acd5ea466c244055e
2025-11-06 14:47:56 -08:00
Tim Oliver
bb6dea7d6d Bump IGListKit to v5.1.0
Summary: Updates the CHANGELOG with all of the latest enhancements and fixes, and bumps the version number of IGListKit to 5.1.0

Reviewed By: benhgreen

Differential Revision: D85926201

fbshipit-source-id: c3c37bbfb859da3ef753b3a8074cf28c8b0febfa
2025-10-30 23:19:01 -07:00
Jerome B
23daf6de72 Provided support for iOS 13 Context Menus (#1430)
Summary:
## Changes in this pull request

Issue fixed: Provided support for Context Menus

### Checklist

- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)

Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1430

Test Plan: https://pxl.cl/2F940

Reviewed By: benhgreen

Differential Revision: D45309023

Pulled By: TimOliver

fbshipit-source-id: 9f3d7871288437414ae3c0d2941802aa506a5553
2025-10-30 21:58:06 -07:00
Tim Oliver
c7de5ef11b Remove iOS 26.0 reference from the GitHub Actions manifest (#1643)
Summary:
I noticed that in the latest commit to main, [the build had started failing](https://github.com/Instagram/IGListKit/actions/runs/18856759807/job/53806413365).

Looking into it, it seems GitHub has removed `iOS 26.0` as a valid destination, replacing it with both `iOS 26.0.1` and `iOS 26.1` on their `macos-26` runner target.

I tried removing the explicit iOS version define in the CI YAML file, but unfortunately, this ended up breaking the UI test target. It turns out that one requires the 'preboot' step in order to work, and without an OS number, the preboot, and xcodebuild steps both arbitrarily choose different simulator slices to execute. :(

On top of that, when I fixed this issue and tried to do a fresh build, `IGSectionMap` was throwing a build error in one of the IGAsserts, requiring that the provided `NSUInteger` needed to be typecast to `(unsigned int)`.

So, in order to fix this moving forward, I went back to macos-14, since we're pretty safe in that iOS 18's build numbers probably won't be updated in that one for a fair while.

Pull Request resolved: https://github.com/instagram/IGListKit/pull/1643

Test Plan: I confirmed the external tests pass, so as long as the internal ones pass too, we should be good!

Reviewed By: m3rlin45

Differential Revision: D85658369

Pulled By: TimOliver

fbshipit-source-id: 78cc0f9d9e9e095bb99c010d844d2186be0017f6
2025-10-28 21:45:43 -07:00
Maxime Ollivier
64ba471201 assert when diffIdentifier changes between updates
Summary:
`diffIdentifier` should not have changed before an update starts, otherwise we can't look up the corresponding section-controller.

Lets add an assert when we detect this issue. In a few months, we should evaluate if this is still useful.

Differential Revision: D85456085

fbshipit-source-id: 9aee649477618e2fdcd5b8e972d8eae0719bed85
2025-10-27 14:38:36 -07:00
Maxime Ollivier
f2fb62a394 add types to IGListSectionMap
Summary: Objects in `IGListSectionMap` should be `id<IGListDiffable>`. This is gonna make the next diff easier too. We probably should do the same with `IGListAdapter`, but that requires a bigger refactor for another time.

Differential Revision: D85372926

fbshipit-source-id: 0b9828ce28bd7906a6abf13d6bb3cc2a9fbb2e9c
2025-10-27 14:38:36 -07:00
Tim Oliver
e7ea4ae174 Add Meta copyright to IGListPerformDiff.m
Summary: One of the implementation files in IGListKit didn't have the appropriate copyright headers, which was causing one of the open source health checks to throw a warning.

Reviewed By: DimaVartanian

Differential Revision: D83947233

fbshipit-source-id: c5ce059373a57b4b235810f42e21bb4ab5181051
2025-10-06 17:22:13 -07:00
Constantine Fry
700905e628 Disable cache invaldation when the collection view perform an insertion of a new page to the list
Summary: See https://docs.google.com/document/d/1DRB_ZUZU15Cm0968zc7N8WmhUF4aFBhnk-GiR4ssVFQ/edit?tab=t.0

Reviewed By: matrush

Differential Revision: D81792852

fbshipit-source-id: c56f652b22d6adea21629f7c950f174892a59b5e
2025-09-08 02:47:19 -07:00
Yury Dymov
0944f8e809 UICollectionViewLayout+InteractiveReordering
Summary:
## Stack
We aim to remove +load methods from the codebase to reduce pre-main startup time and to unblock enabling startup optimizations

## Diff
UICollectionViewLayout+InteractiveReordering marked as Internal in IGListKit. I am assuming that this is an internal implementation detail of the IGListKit and is not supposed to run globally outside of the IGListKit context. Based on that assumption I migrated global +load API to a `setup` method, which is being execution in IGListAdapter constructor, core class of the IGListKit library

Reviewed By: AfrazCodes

Differential Revision: D81592721

fbshipit-source-id: 718b936e669669c66ec5b6c80fefc4bd106170c2
2025-09-04 08:24:17 -07:00
Maxime Ollivier
fec6b0ef0f add autoDeselectEnabled to IGListAdapter
Summary: We're finding ourselves with the need to delesect a lot of cells, but still allow selction. We could do it in each section-controller, but it's easy to mess up and forget in new section-controllers. So, lets add "auto deselection" to `IGListAdapter` directly. When enabled, section-controllers still get the `-didSelect`, but they don't need to deselect the cell.

Differential Revision: D80272474

fbshipit-source-id: 3d905f1f37def6af3cbc6f4d35e256826b7555fb
2025-08-15 07:56:14 -07:00
Alex Oakley
101665de09 Adding missing NS_UNAVAILABLE NSCoder constructor declaration to IGListKit
Summary:
### Context

This stack implements base `UIKit` types in Objective-C by removing the requirement to provide `NSCoder` based constructor in Swift.

### This diff

`IGListKit` seems to have `NSCoder` constructors marked unavailable except for the single type `IGListCollectionViewLayout`. So adding it there.

### Project context / references

[Opti project](https://fburl.com/gdoc/7hekhwd5)
[META UIKit RFC](https://fburl.com/gdoc/9maag852)

Reviewed By: TimOliver

Differential Revision: D77116862

fbshipit-source-id: 9ae48258131a439b1e8ae84ac23ff5ea14b87281
2025-06-24 19:38:02 -07:00
Amit Kumar
a37a0ca1b7 Enable Swift 6 on IGAvatarUnlockableQuestsUI
Summary: ^

Differential Revision: D76170610

fbshipit-source-id: 9d464eff0c215f98622fa1f1d44e3cc38c77f048
2025-06-07 13:41:35 -07:00
Nolan O'Brien
8aff5ce1a3 Handle unexpected (out-of-range) cases in switch statements for CompilerWarningLevel.HIGH targets
Summary: For `CompilerWarningLevel.HIGH` targets (except Instagram), let's address `switch` without `default` present

Reviewed By: aary

Differential Revision: D75460752

fbshipit-source-id: dd0a4594421580b745b7bb866efe4a86d3061d6d
2025-05-28 09:28:35 -07:00
Amit Kumar
6451aee059 Enabled Swift 6 on IGFitnessStickersUI
Summary: Many protocols that are conformed only by VCs needed to be marked main actor.

Reviewed By: ebgraham

Differential Revision: D74761535

fbshipit-source-id: b5d047b625df5cf16759aa5c19e5bf57594a3d99
2025-05-15 10:51:05 -07:00
Maxime Ollivier
9106963a39 add experimental fix for preferredFocusedView
Summary: The default implementation of `-[UICollectionView preferredFocusedView]` can create/dequeue off-screen cells, which causes perf issues and bugs. Lets create `IGListExperimentFixPreferredFocusedView` to return a visbile index-path.

Differential Revision: D74484148

fbshipit-source-id: f710be56b938f8474278cf88b7e2e4268f702f1d
2025-05-09 12:09:43 -07:00
Maria Roodnitsky
59255166b2 Fix 'veiw' mispelling
Summary:
Easy little diffs to correct the spelling heathens of the past. O:)

As titled.

Differential Revision: D73490845

fbshipit-source-id: f8868eb5a1ebaac771e73d832baa1245a9cd2c5a
2025-04-28 21:05:48 -07:00
Jesse Seidman
d1d6f9d52c Add IGListAdapterDelegate Methods 2/n
Summary:
## CONTEXT
`IGListAdapterDelegate` currently has methods that are fired when an object is *first* displayed and when an object *ended* display on screen.  For many use cases this works but there are use cases in which it would be helpful to know whenever a cell will be displayed or ends display.  This is especially relevant in the `IGListAdapterDelegateAnnouncer` which will enable you to add code for tracking cells globally.  This change also balances the `IGListAdapterDelegate` with `IGListDisplayDelegate`  which has methods which include the cell as well

## PLAN
This diff will be go out in multiple parts
- delegate method addition (many file change due to our pattern of not preferring default implementation of protocol methods)
- Update to `IGListDisplayHandler` and `IGListAdapterDelegateAnnouncer` for invocation of delegate methods
- Unit test additions

## THIS DIFF
This diff changes adds the invocation of `IGListAdapterDelegate` in `IGListDisplayHandler` and `IGListAdapterDelegateAnnouncer`.  The cell lifecycle method will be called every time. cell will display and did end display as opposed to the existing methods which are only called the *first* and *last* time an object is displayed

Differential Revision: D70348078

fbshipit-source-id: 820cd22af217f01f2d4916a70e203d9afc4c6a6d
2025-04-24 13:07:16 -07:00
Jesse Seidman
fa50aa1cf1 Add IGListAdapterDelegate Methods 1/n
Summary:
## CONTEXT
`IGListAdapterDelegate` currently has methods that are fired when an object is *first* displayed and when an object *ended* display on screen.  For many use cases this works but there are use cases in which it would be helpful to know whenever a cell will be displayed or ends display.  This is especially relevant in the `IGListAdapterDelegateAnnouncer` which will enable you to add code for tracking cells globally.  This change also balances the `IGListAdapterDelegate` with `IGListDisplayDelegate`  which has methods which include the cell as well

## PLAN
This diff will be go out in multiple parts
- delegate method addition (many file change due to our pattern of not preferring default implementation of protocol methods)
- Update to `IGListDisplayHandler` and `IGListAdapterDelegateAnnouncer` for invocation of delegate methods
- Unit test additions

## THIS DIFF
This diff changes the delegate to include the methods that pass in the cell.  This is a huge many file diff because we prefer to not include default implementations of protocol methods.  This makes the delegate change a breaking change.

Reviewed By: maxolls

Differential Revision: D70348102

fbshipit-source-id: 40709ba8a9112d8855d5ce5ecfd5930b5c79bf26
2025-04-24 13:07:16 -07:00
Nolan O'Brien
d0d38c4a33 Fix up warnings to get Instagram code onto CompilerWarningLevel.HIGH
Summary:
many fixes for making IG `.HIGH` in warning level

https://fb.workplace.com/groups/iOSDevQA/posts/28237779439177303

Differential Revision: D72878674

fbshipit-source-id: 9f53bc19aa534c1c2252446faf06ef2c8dc20612
2025-04-14 15:23:41 -07:00
Nolan O'Brien
431ae719dc Fix up places to get Instagram hierarchy of code onto CompilerWarningLevel.HIGH
Summary:
many fixes for making IG `.HIGH` in warning level

https://fb.workplace.com/groups/iOSDevQA/posts/28237779439177303

Differential Revision: D72679686

fbshipit-source-id: 592b61515ca1480a0b37ebd35c88786f9e1b3469
2025-04-11 12:19:53 -07:00
Tim Oliver
7e6a493dca General fixes to restore GitHub CI (#1622)
Summary:
The GitHub CI seems to be failing still since we added some new header files and didn't include the necessary ones in the IGListKit.h umbrella header.

This PR:

* Updates the umbrella header to include the new header files
* Updates the visibility of the private headers so they don't need to be included in the umbrella.
* Does a general clean-up of the Xcode project, re-ordering all of the newly imported files.

Assuming this all passes the external CI, we can land it in Phabricator.

Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1622

Test Plan: GitHub CI has passed: https://github.com/Instagram/IGListKit/actions/runs/13851019458

Reviewed By: fabiomassimo

Differential Revision: D71178515

Pulled By: TimOliver

fbshipit-source-id: 1ea643a7bc7a401c45af2776c2a66e3b806035d7
2025-03-14 23:56:06 -07:00
Hoa Dinh
0534ee22c4 _finishWithoutUpdate is not used
Summary: deletedelete

Reviewed By: dstnbrkr

Differential Revision: D71137052

fbshipit-source-id: 38e4998bc69a9f88fdff27d2b46895a211292892
2025-03-13 13:08:41 -07:00
bartoszpawelczyk
24eee66aed Fix missing project and SPM references (#1621)
Summary:
## Changes in this pull request

Issue fixed: [1620](https://github.com/Instagram/IGListKit/issues/1620)

### Checklist

- [ ] All tests pass. Demo project builds and runs.
- [ ] I added tests, an experiment, or detailed why my change isn't tested.
- [ ] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes.
- [ ] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/main/.github/CONTRIBUTING.md)

Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1621

Test Plan:
Tested that IG builds with these changes without issue. All seems good.
As

Reviewed By: NSProgrammer

Differential Revision: D70959852

Pulled By: TimOliver

fbshipit-source-id: 087411463ad1b7c0698d7aba543d85c9013abf39
2025-03-11 09:13:03 -07:00
Nolan O'Brien
e3523b36a4 Add indexesOfVisibleObjects
Summary:
It's inefficient to get the unordered array of visibleObjects to then try to find the order of those objects after.  Instead, introduce a new `indexesOfVisibleObjects` API to `IGListAdapter` which will inherently preserve order.

Will use this to help find the previous and next "item" to scroll to with Main Feed.

Differential Revision: D70835725

fbshipit-source-id: a5f66681e0184299d92f220be194b5554639a7da
2025-03-09 16:08:54 -07:00
Maxime Ollivier
9c0ef52715 add associatedListAdapters to UIViewController
Summary: We'd like to know which `IGListAdapter` is associated with a `UIViewController`, so lets keep track of that.  Every adapter should have only 1 controller and it can't change.

Differential Revision: D70631091

fbshipit-source-id: 7f818d7e8f1858a4c80e223be6d5aad5cfc639cf
2025-03-05 13:42:36 -08:00
Hoa Dinh
c93d0675d9 T202656292: Error: NSInternalInconsistencyException at UIKit/UIKitCore:-[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttribut - more debug info
Summary: Adding more debug info to figure out what's happening in sundial.

Differential Revision: D70545124

fbshipit-source-id: f0ce51529a712328941b9f9b08b70894388bdb14
2025-03-04 14:27:03 -08:00
Jordan Smith
6e9129978e Fix crash on nil attributes value
Summary:
## Context

UICollectionViews are allowed to return nil attribute values; it is not a programmer error and in some cases it can be used as a feature. `IGListCollectionViewLayout` doesn't consider this; if subclasses return nil attributes then a crash will occur.

## This Diff

Let's apply a check to ensure the attribtues are non-nil before adding to the result array.

Differential Revision: D70492114

fbshipit-source-id: b7203ded2928d2892693f95bb56b45f03c2530a2
2025-03-03 12:42:14 -08:00
Hoa Dinh
7f8b5b4ff5 T202656292: Error: NSInternalInconsistencyException at UIKit/UIKitCore:-[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttribut - log when sectionController is nil
Summary: Also log when the sectionController is nil.

Differential Revision: D70050304

fbshipit-source-id: c4f9c5af10c1266012368be27cc5bd32610194a8
2025-02-23 11:38:00 -08:00
Jordan Smith
1560956da3 Expose IGListCollectionViewLayoutInvalidationContext
Summary:
## Context

`IGListCollectionViewLayout` users may have need to know more about the invalidation contexts it uses -- either to supply accurate invalidation contexts, or to understand more about invalidations (example -- usages of preferred layout attributes).

## This Diff

Exposes `IGListCollectionViewLayoutInvalidationContext` publicly, and renames properties to something a little nicer.

Differential Revision: D69679455

fbshipit-source-id: 2bd3e414ea1f48522546854d0287f3ca9d873ec6
2025-02-16 13:23:51 -08:00
Hoa Dinh
da1050ef39 Additional debugging info when IGListKit collection view could crash
Summary: Add more metadata when we return nil cells in IGListKit.

Differential Revision: D69577117

fbshipit-source-id: 0834857eb429154f35bacf7e00d347ce99d28ee6
2025-02-13 15:15:08 -08:00
Hoa Dinh
af68415b38 Added assert when returned -sectionControllerForSection is nil
Summary: When the value is nil, it will result in a crash on iOS 18.

Differential Revision: D69565468

fbshipit-source-id: 5936ec253cd1e0dfb8b494ebb1364c6a14e79170
2025-02-13 09:36:58 -08:00
Sash Zats
478a139ffa Fix point coordinate space being wrong
Summary: We were not passing the right coordinates when finding the indexPath of the cell we are hovering over causing all sort of havoc

Differential Revision: D69207295

fbshipit-source-id: 9b2df93ae00eceb85fde86f766a3b225fc8c56f9
2025-02-05 20:32:02 -08:00
Sash Zats
bcc42df023 IGListKit add -[IGCollectionContext layoutAttributesForItemAtIndex:]
Summary: This allows to get `layoutAttributesForItemAtIndex` for a given cell via list kit, not directly via UICollectionView → layout → …

Reviewed By: avielg

Differential Revision: D68189875

fbshipit-source-id: 9f81143d1a78ade6b9c14b3c012f22f222ded5b2
2025-01-25 20:19:49 -08:00
Maxime Ollivier
7b78c95ed1 clean up ig_ios_listkit_fix_net_item_count
Summary: This was a killswitch to be safe, so lets clean it up.

Differential Revision: D67072925

fbshipit-source-id: ac54972030e7d53e7abd95025e45773aa3c5efc6
2024-12-12 04:02:03 -08:00
Mark Davis
0ec2d526f3 Disable automatic async conversion for IGListAdapter APIs
Summary:
Threads has now run into multiple instances of device-only crashes resulting from usage of automatically converted Swift async versions of `performUpdates(animated:)` and `reloadData()`.

See D64428846, D64876801.

The crashes appear to stem from the opaque, automatically generated async methodology:

```
objc completion handler block implementation for escaping callee_unowned convention(block) (unowned Bool) -> () with result type Bool
```

Our `IGListKit` infra assuming ownership of these `callee_unowned` blocks seems to be problematic: the block can be released/nil'd, and our downstream [`[-[IGListReloadTransaction _executeCompletionBlocks:]`](https://www.internalfb.com/intern/logview/redirect/?filename=IGListReloadTransaction.m&line=82&repo=fbsource&revision=c1e4b4a34ff90e4785983b260f10543af6536215&build=655525612) execution then crashes.

Given this incompatibility with automatic conversion, here I propose:
1. marking the relevant `IGListAdapter.h` APIs with `NS_SWIFT_DISABLE_ASYNC`
2. providing manual async APIs in a new `IGListAdapter+Async.swift` extension hosted in `IGListSwiftKit` that existing callers can now make use of.

Differential Revision: D64881920

fbshipit-source-id: b15a5141a79491c1871b92f4f84a0c29b6045ee0
2024-10-25 12:55:13 -07:00
Maxime Ollivier
636f6b5a3d create global IGListAdapterDelegateAnnouncer
Summary:
In a few cases, we need to listen to all `IGListAdapter` events. We bend over backwards to detect adapters and swap their delegate with a proxy objects. Lets make things simpler and build it right into `IGListKit` by allowing global announcers, starting with `IGListAdapterDelegate`, but we could expand to the others if we like this.

Generally, we want to avoid anything global, but given the complexity of the alternative, this feels like the better tradeoff.

Differential Revision: D64042609

fbshipit-source-id: 0ca6bada27e640fee5a231148427be41994e4d43
2024-10-09 11:38:29 -07:00
Maxime Ollivier
4bad7d5260 add assert for iOS 18 supplementary view dequeue exceptions
Summary: Same as last diff, but for supplementary views!

Differential Revision: D62813794

fbshipit-source-id: f1630fd49740b1b34b422a0b4fd3055a3f0f0b21
2024-09-17 07:11:55 -07:00
Maxime Ollivier
ab94446c63 add assert for iOS 18 cell dequeue exceptions
Summary:
iOS 18 has new exceptions, which can be a bit tough to debug. The common ones we see:
1. Cell dequeue outside of -cellForIndex
2. Dequeue being called more than once
3. Returning a cell that was not dequeued

Lets add an assert for each. #1 and #2 can actually assert on the problematic call, which will give a nice stack strace. #3 will still have a generic stack trace, but at least we'll see the section-controller.

Differential Revision: D62809660

fbshipit-source-id: 454c44598d4b21e09e6f66eb63c502b1b966a993
2024-09-17 07:11:55 -07:00