Skip to content

Fix: Transfer leadingScreensForBatching from pending state on node load#2130

Merged
rcancro merged 5 commits intoTextureGroup:masterfrom
GianmarcoFolchi:gfolchi/leadingScreensForBatchingFix
Nov 19, 2025
Merged

Fix: Transfer leadingScreensForBatching from pending state on node load#2130
rcancro merged 5 commits intoTextureGroup:masterfrom
GianmarcoFolchi:gfolchi/leadingScreensForBatchingFix

Conversation

@GianmarcoFolchi
Copy link
Copy Markdown
Contributor

@GianmarcoFolchi GianmarcoFolchi commented Nov 18, 2025

Problem

When leadingScreensForBatching is set on ASCollectionNode or ASTableNode before the node loads, the value is not properly transferred to the underlying view. This causes the property to retain the default value of 2.0 instead of the configured value.

Root Cause

It looks like leadingScreensForBatching was accidentally omitted when transferring the pendingState to the view in the didLoad function.

Examples

Broken Example

- (instancetype)init {
    self = [super init];
    if (self) {
        _collectionNode = [[ASCollectionNode alloc] init...];
        _collectionNode.leadingScreensForBatching = 3.6;  // Stored in pending state but never transferred to view
        [self addSubnode:_collectionNode];
    }
    return self;
}

Result: leadingScreensForBatching stays at 2.0

Working Example

override func didLoadInternal() {
    let collectionView = collectionNode.view  // This triggers node load
    collectionNode.leadingScreensForBatching = 2.4  // Set after load, goes directly to view
}

Result: leadingScreensForBatching is correctly set to 2.4 since the view had already been loaded.

leadingScreensForBatching setter: leadingScreensForBatching goes to pendingState if it exists else it goes to the underlying view. The pendingState value wasn't being transferred to the underlying view on view creation.

- (void)setLeadingScreensForBatching:(CGFloat)leadingScreensForBatching
{
  if ([self pendingState]) {
    _pendingState.leadingScreensForBatching = leadingScreensForBatching;
  } else {
    ASDisplayNodeAssert([self isNodeLoaded], @"ASCollectionNode should be loaded if pendingState doesn't exist");
    self.view.leadingScreensForBatching = leadingScreensForBatching;
  }
}

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Gianmarco seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@GianmarcoFolchi GianmarcoFolchi force-pushed the gfolchi/leadingScreensForBatchingFix branch from e7aab67 to 1d63a8c Compare November 18, 2025 21:36
Comment thread Source/ASCollectionNode.mm Outdated
Comment thread Source/ASCollectionNode.mm Outdated
Comment thread Source/ASTableNode.mm Outdated
@rcancro rcancro merged commit 34de002 into TextureGroup:master Nov 19, 2025
2 of 11 checks passed
3a4oT pushed a commit to 3a4oT/Texture that referenced this pull request Mar 29, 2026
…ad (TextureGroup#2130)

* Fix: Transfer leadingScreensForBatching from pending state on node load
and add tests

* Address PR comments

* try to fix build

* Adding whitespace to see if builds run

* Revert prev commit to check if builds are working

---------

Co-authored-by: Gianmarco <gfolchi@pinterest.com>
3a4oT added a commit to 3a4oT/Texture that referenced this pull request Apr 1, 2026
…#7)

* Fix: Transfer leadingScreensForBatching from pending state on node load (TextureGroup#2130)

* Fix: Transfer leadingScreensForBatching from pending state on node load
and add tests

* Address PR comments

* try to fix build

* Adding whitespace to see if builds run

* Revert prev commit to check if builds are working

---------

Co-authored-by: Gianmarco <gfolchi@pinterest.com>

* Update CI workflow for Xcode 26 and actions checkout version

- Updated DEVELOPER_DIR to Xcode_26.0.1 in all CI workflows
- Updated build.sh SDK from iphonesimulator17.4 to iphonesimulator26.0
- Updated simulator device from iPhone SE (3rd generation) to iPhone 17
- Updated actions/checkout from v2 to v4
- Changed runs-on from macos-latest to macos-15 for explicit versioning
- Verified all build configurations (framework, carthage, tests, examples)

* Add Swift Package Manager support with IGListKit integration

Add comprehensive SPM support using Swift 6.2 package traits for modular features.

Core features:
- Package.swift with AsyncDisplayKit and TextureIGListKitExtensions products
- Default traits (Video, MapKit, Photos, AssetsLibrary) match CocoaPods defaults
- Optional IGListKit trait with pure Swift implementation
- TextNode2 (modern TextNode) enabled by default
- PINRemoteImage always included

IGListKit integration:
- Pure Swift implementation (traits don't work with Objective-C #if directives)
- ListAdapter.setCollectionNode(_:) replaces Objective-C setASDKCollectionNode:
- Uses IGListKit 5.0+ (breaking changes from 4.x in CocoaPods/Carthage)
- Runtime protocol conformance for ASCollectionDataSourceInterop

Infrastructure:
- SPM source layout generation script (scripts/generate_spm_sources_layout.swift)
- Symlinks from Source/ to spm/Sources/AsyncDisplayKit/
- Build script modes: spm-texture-basic and spm-texture-iglistkit
- CI jobs for both configurations with layout validation

Testing:
- SPMBasic example: 15 tests for core AsyncDisplayKit + PINRemoteImage
- SPMWithIGListKit example: 4 tests for IGListKit integration
- All tests passing

Documentation:
- README with usage examples and CocoaPods migration table
- CONTRIBUTING with SPM layout regeneration instructions
- Comprehensive TextureIGListKitExtensions guide

Reference implementations: Source/IGListAdapter+AsyncDisplayKit.mm,
Source/Private/ASIGListAdapterBasedDataSource.mm

* Add iOS app integration example and improve SPM documentation

- Add ASIGListKitSPM example demonstrating local package wrapper approach for iOS apps
- Update TextureIGListKitExtensions README with iOS/tvOS app integration guide
- Add spm-app-iglistkit build mode to test iOS app integration
- Improve SPM test strategy: spm-texture-basic tests committed files, spm-texture-iglistkit tests generation script
- Update example READMEs with clear documentation structure

* Update Swift tools version to 6.1 and add SPM badge

- Change swift-tools-version from 6.2 to 6.1 in all Package.swift files
- Package Traits feature was introduced in Swift 6.1 (SE-0450)
- Update documentation to reflect Swift 6.1+ requirement
- Add Swift Package Manager badge to README

* Remove deprecated AssetsLibrary and non-functional Video/MapKit/Photos SPM traits

- Remove AssetsLibrary (deprecated iOS 9.0)
- Remove Video/MapKit/Photos traits that don't work with Swift via SPM
- Update documentation explaining SPM limitations with conditional compilation
- Recommend CocoaPods/Carthage for users needing these features

Technical details:
Objective-C classes wrapped in preprocessor conditionals (#if AS_USE_VIDEO)
are not exported in Swift module interface, making these traits non-functional
for Swift users even when enabled.

Tests: spm-texture-basic and spm-texture-iglistkit pass

* Add Swift wrapper for IGListKit supplementary views

- Add SupplementaryViewSourceMethods enum with viewForSupplementaryElement and sizeForSupplementaryView
- Replaces unavailable ASIGListSupplementaryViewSourceMethods for SPM users
- Comprehensive documentation with step-by-step examples
- Migration guide from Objective-C implementation

Fixes issue where ASIGListSupplementaryViewSourceMethods is inaccessible from Swift when using SPM with traits due to #if AS_IG_LIST_KIT wrapping.

* Update SPM sources layout script and add symlinks for ASDefaultImageDownloader

* Refactor SPM integration and remove UICoreKit example

- Updated Package.swift to enhance SPM source distribution for Texture, including detailed documentation on IGListKit integration and limitations.
- Removed deprecated UICoreKit example, including its Package.swift, source files, and tests, to streamline the project.
- Added module.modulemap for AsyncDisplayKit to eliminate umbrella header warnings.
- Adjusted build settings in project.pbxproj to reflect the removal of UICoreKit and ensure proper integration of TextureIGListKitExtensions.

* - Improved structure and clarity of the README to facilitate better understanding for developers integrating with iOS/tvOS projects.

* Update CI workflow and project configuration for AsyncDisplayKit integration
- Removed the custom module.modulemap for AsyncDisplayKit to prevent issues with C++ headers, allowing SPM to generate its own automatically.

* [Xcode 26] Fix chained comparison errors in ASTextLayout.mm

Replace 'a < b < c' with correct ternary 'a < b ? prev : next' in
-insideComposedCharacterSequences and -insideEmoji blocks. Clang in
Xcode 26 now treats chained comparisons as a hard error (-Wparentheses).

* Update CI workflow and build.sh to Xcode 26.4

- Updated DEVELOPER_DIR to Xcode_26.4 in all CI workflows
- Updated runs-on from macos-15 to macos-26
- Updated build.sh SDK from iphonesimulator26.0 to iphonesimulator26.4
- Updated simulator OS from 26.0 to 26.4

* Add SectionControllerMethods to TextureIGListKitExtensions

Swift equivalent of ASIGListSectionControllerMethods for SPM builds:
- cellForItem(at:sectionController:) dequeues _ASCollectionViewCell via context
- sizeForItem(at:) returns .zero (AsyncDisplayKit handles sizing)

* Fix CI: use iOS 26.2 simulator and Xcode 26.3 (26.4 runtime not installed on runner)

* Fix CI: use iPhone 17 with iOS 26.2 simulator (iPhone 16 not available on runner)

* Fix SPMWithIGListKit: remove IGListKit trait (now always included in Texture)

---------

Co-authored-by: Gianmarco <53410676+GianmarcoFolchi@users.noreply.github.com>
Co-authored-by: Gianmarco <gfolchi@pinterest.com>
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

Successfully merging this pull request may close these issues.

3 participants