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

Node should always be marked invisible before deallocating #145

Closed
garrettmoon opened this issue May 1, 2017 · 15 comments
Closed

Node should always be marked invisible before deallocating #145

garrettmoon opened this issue May 1, 2017 · 15 comments

Comments

@garrettmoon
Copy link
Member

From @Dominionys on September 15, 2016 11:39

AsyncDisplayKit version - '1.9.90'
'1.9.81' works fine.

Hi, can you help me with it? I have a ASTableNode on ViewController (not AS). For example i have 5 section with random number of rows, and if i will scroll table to bottom then to top and reloadSection (for example) 3 section (not on the screen), everything is good. But if i didn't scroll and reload table, app will crash. All nodes are layerBacked = false.
Reload section: self?.tableViewCompany.tableNode.view.reloadSections(indexSet, withRowAnimation: UITableViewRowAnimation.Fade)
Cell example:`
class CompanyCellNodeItem: AbstractNodeCell {

var viewImage:          ASNetworkImageNode!
var viewLabelDate:      ASTextNode!
var viewLabelTitle:     ASTextNode!
var viewLabelSubtitle:  ASTextNode!
var isNeedTopView:      Bool           = true


init(type:CompanyInfo, separator:Bool) {
    super.init(separator: separator)

    viewImage = {
        let view = ASNetworkImageNode.with(Alpha:0.0, Mode:.ScaleToFill, Color:.whiteColor())
        view.layerBacked = false
        view.defaultImage = UIImage(named: "image_placeholder.png")
        view.preferredFrameSize = CGSize(width: 80, height: 50)
        return view
    }()

    viewLabelTitle = {
        let view = ASTextNode.init()
        view.layerBacked = false
        view.maximumNumberOfLines = 2
        return view
    }()

    viewLabelSubtitle = {
        let view = ASTextNode.init()
        view.layerBacked = false
        view.maximumNumberOfLines = 2
        return view
    }()

    viewLabelDate = {
        let view = ASTextNode.init()
        view.placeholderInsets = UIEdgeInsetsZero
        view.preferredFrameSize = CGSizeMake(30, 10)
        view.layerBacked = false
        view.attributedText = NSAttributedString.attributedCompanyItemDate("25.12.12")
        return view
    }()


    addSubnode(viewImage)
    addSubnode(viewLabelTitle)


    switch type {
    case .Gift:
        isNeedTopView = false
        addSubnode(viewLabelSubtitle)
    case .Event:
        addSubnode(viewLabelSubtitle)
    case .News:
        addSubnode(viewLabelDate)
    default:
        break
    }

}

override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec {

    let spacer = ASLayoutSpec()
    spacer.flexGrow = true

    let layoutHorizontalDateInfo = ASStackLayoutSpec(
        direction: .Horizontal,
        spacing: 0,
        justifyContent: .Start,
        alignItems: .Start,
        children: [viewLabelDate ,spacer])

    viewLabelTitle.spacingAfter   = 3.0

    let verticalChildren:[ASLayoutable] = isNeedTopView ?
                                           [layoutHorizontalDateInfo,viewLabelTitle,viewLabelSubtitle]
                                         : [viewLabelTitle,viewLabelSubtitle]


    let layoutVertical = ASStackLayoutSpec(
        direction: .Vertical,
        spacing: 0,
        justifyContent: .Center,
        alignItems: .Stretch,
        children: verticalChildren)

    layoutVertical.flexShrink = true
    layoutVertical.flexGrow   = true
    layoutVertical.alignSelf  = .Center

    let layoutHorizontalMain =  ASStackLayoutSpec(
        direction: .Horizontal,
        spacing: 15,
        justifyContent: .Start,
        alignItems: .Start,
        children: [ viewImage, layoutVertical,viewImageArrow ])

    layoutHorizontalMain.spacingAfter  = 8
    layoutHorizontalMain.spacingBefore = 8
    let layoutSeparator = self.addTopSeparator(layoutHorizontalMain)

    return self.addDefaultEdgeInsets(layoutSeparator)
}

`

Trace log: 2016-09-15 18:35:10.694 Prestige[3690:1807714] *** Assertion failure in -[Prestige.CompanyNodeNew dealloc], /Users/Unfeeling/XcodeProjects/Pods/AsyncDisplayKit/AsyncDisplayKit/ASDisplayNode.mm:382 2016-09-15 18:35:10.700 Prestige[3690:1807714] *** Assertion failure in -[ASImageNode dealloc], /Users/Unfeeling/XcodeProjects/Pods/AsyncDisplayKit/AsyncDisplayKit/ASDisplayNode.mm:382 2016-09-15 18:35:10.703 target[3690:1807714] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Node should always be marked invisible before deallocating; interfaceState: 15, <ASImageNode: 0x173da200>' *** First throw call stack: (0x254e391b 0x24c7ee17 0x254e37f1 0x25cc7529 0xb3977d 0xb72415 0xb1dcd9 0xacb3bb 0xac8da3 0x29d617d1 0x29a5621b 0x29a591b5 0xb56251 0x24c7df55 0x24c87ddf 0x24c87e03 0xb39ab9 0xb1dcd9 0x253fad99 0x24c98f67 0x253fad99 0x24c98f67 0x24c993a9 0x253f2f89 0x254a406f 0x253f3229 0x253f3015 0x269e3ac9 0x29ac5189 0x3d2770 0x2509b873) libc++abi.dylib: terminating with uncaught exception of type NSException

Copied from original issue: facebookarchive/AsyncDisplayKit#2252

@garrettmoon
Copy link
Member Author

From @hannahmbanana on October 7, 2016 7:8

@Dominionys: It's odd that this has regressed between 1.9.81 and 1.9.90. A few questions:

  • Is this 100% reproducible?
  • Could you see if it is reproducible on our releases/p6.13 branch (stable version of ASDK that Pinterest ships with - has a few small API changes so we haven't released a cocoapod yet). It should be easy to point your podfile to this branch and run pod update.

@garrettmoon
Copy link
Member Author

From @hannahmbanana on November 15, 2016 4:8

@Dominionys - Are you still seeing this issue? I'm going to close this issue given the length of time since the thread was active. Feel free to re-open the issue if you are still having this issue.

@garrettmoon
Copy link
Member Author

From @nhatlee on November 25, 2016 10:36

I still got the same crash on SDK version beta 2.
my code:
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let _view = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 50)) let textNode = ASTextNode() textNode.isLayerBacked = true textNode.backgroundColor = UIColor.clear textNode.attributedText = NSAttributedString( string: "All Categories", attributes: [ NSFontAttributeName: UIFont.systemFont(ofSize: 20), NSForegroundColorAttributeName: UIColor.black, NSKernAttributeName: -0.3 ]) _view.addSubnode(textNode) return _view }
The crash log:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Node should always be marked invisible before deallocating. Node: <ASTextNode: 0x7fb08d01b000; text = "All Categories">'

@garrettmoon
Copy link
Member Author

From @hannahmbanana on November 27, 2016 21:8

@nhatlee - thank you for reporting! Is this issue 100% reproducible for you? Would it be possible for you to include a sample project here or emailed to [email protected]?

cc @Adlai-Holler

@garrettmoon
Copy link
Member Author

From @tomizimobile on November 29, 2016 20:32

@hannahmbanana @Adlai-Holler I've also come across this issue. I found it in a specific view controller of mine, and I think having a non-translucent tabBar might be part of the issue (at least for me). Using aa9dff0. Just run the sample project and hit the reload button without scrolling. Seems to be happening across a variety of simulators, tried it on 5S, 6S and 6S+

ASDK-crash.zip

@garrettmoon
Copy link
Member Author

From @Adlai-Holler on November 30, 2016 17:1

@tomizimobile Thanks for an excellent repro! I turned it into a unit test case and resolved the issue in the linked PR. Could you and @nhatlee verify that the issue is fixed?

@garrettmoon
Copy link
Member Author

From @tomizimobile on November 30, 2016 19:15

@Adlai-Holler I'm still seeing the issue in my current project. I've been trying to recreate it in a separate project but haven't been able to reproduce it there so far.

@garrettmoon
Copy link
Member Author

From @tomizimobile on November 30, 2016 19:45

@Adlai-Holler alright, finally tracked it down. Seemed to be ok with a grouped tableView, but this is happening with a plain tableView.

ASDK-crash.zip

@garrettmoon
Copy link
Member Author

From @stephenkopylov on February 6, 2017 16:33

Have the same issue with plain tv + section header views.
Grouped tv works fine

ASDK v2.0.2

@garrettmoon
Copy link
Member Author

From @9you on April 28, 2017 9:3

I still facing this problem on Texture 2.3

@temkich
Copy link

temkich commented May 2, 2017

I seem to have exactly the same problem with AsyncDisplayKit (2.2.1)

2017-04-29 15:51:39.379598+0300 iOSmyApp[1922:702805] file:///var/mobile/Containers/Data/Application/745FC557-B6E7-4428-89F6-6B958651CDD9/Documents/default.realm 
2017-04-29 15:51:57.423711+0300 iOSmyApp[1922:702805] *** Assertion failure in -[NKLTableCellNode dealloc], /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/ASDisplayNode.mm:410 
2017-04-29 15:51:57.433245+0300 iOSmyApp[1922:702805] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Node should always be marked invisible before deallocating. Node: <NKLTableCellNode: 0x132115a00>' 
*** First throw call stack: 
(0x183c62fd8 0x1826c4538 0x183c62eac 0x1846fa710 0x100149400 0x183c529a4 0x183b469e0 0x183c529a4 0x183b469e0 0x100123e50 0x1001bae10 0x1011a1a50 0x1011a1a10 0x1011a6b78 0x183c110c0 0x183c0ecdc 0x183b3ed94 0x1855a8074 0x189df7130 0x100063e3c 0x182b4d59c) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb)

Thread 1Queue : com.apple.main-thread (serial)
#0 0x0000000182c5d014 in __pthread_kill ()
#10 0x00000001846fa710 in -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] ()
#11 0x0000000100149400 in ::-[ASDisplayNode dealloc]() at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/ASDisplayNode.mm:410
#12 0x0000000183c529a4 in common_removeAllObjects ()
#15 0x0000000183b469e0 in -[__NSArrayM dealloc] ()
#16 0x0000000100123e50 in ::__50-[ASDataController endUpdatesAnimated:completion:]_block_invoke_2() at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASDataController.mm:603
#17 0x00000001001bae10 in ::__30-[ASMainSerialQueue runBlocks]_block_invoke() at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASMainSerialQueue.mm:62
#18 0x00000001011a1a50 in _dispatch_call_block_and_release ()
#25 0x0000000189df7130 in UIApplicationMain ()
#26 0x0000000100063e3c in main at /Users/testUser/dev/iOSmyApp/iOSmyApp/Application/main.m:14
#27 0x0000000182b4d59c in start ()
Enqueued from org.AsyncDisplayKit.ASDataController.editingTransactionQueue:0x174106c00 (Thread 8)Queue : org.AsyncDisplayKit.ASDataController.editingTransactionQueue:0x174106c00 (serial)
#0 0x00000001011ad304 in _dispatch_queue_push ()
#1 0x0000000100193538 in ASPerformBlockOnMainThread at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Private/ASInternalHelpers.m:72
#2 0x00000001001bac70 in ::-[ASMainSerialQueue runBlocks]() at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASMainSerialQueue.mm:67
#3 0x00000001001bab5c in ::-[ASMainSerialQueue performBlockOnMainThread:](dispatch_block_t) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASMainSerialQueue.mm:44
#4 0x000000010011d778 in ::-[ASDataController insertNodes:ofKind:atIndexPaths:completion:](NSArray *, NSString *, NSArray *, ASDataControllerCompletionBlock) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASDataController.mm:265
#5 0x000000010011f904 in ::-[ASDataController _insertNodes:atIndexPaths:withAnimationOptions:](NSArray *, NSArray *, ASDataControllerAnimationOptions) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASDataController.mm:349
#6 0x000000010011c43c in ::__80-[ASDataController _batchLayoutAndInsertNodesFromContexts:withAnimationOptions:]_block_invoke(NSArray *, NSArray *) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASDataController.mm:192
#7 0x000000010011bbdc in ::-[ASDataController batchLayoutNodesFromContexts:batchCompletion:](NSArray *, ASDataControllerCompletionBlock) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASDataController.mm:165
#8 0x000000010011c368 in ::-[ASDataController _batchLayoutAndInsertNodesFromContexts:withAnimationOptions:](NSArray *, ASDataControllerAnimationOptions) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASDataController.mm:190
#9 0x00000001001258a8 in ::__56-[ASDataController insertSections:withAnimationOptions:]_block_invoke() at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASDataController.mm:717
#10 0x00000001011a1a50 in _dispatch_call_block_and_release ()
#18 0x0000000182d22d7c in start_wqthread ()
Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial)
#0 0x00000001011ad304 in _dispatch_queue_push ()
#1 0x0000000100125608 in ::-[ASDataController insertSections:withAnimationOptions:](NSIndexSet *, ASDataControllerAnimationOptions) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASDataController.mm:706
#2 0x0000000100124838 in ::-[ASDataController updateWithChangeSet:animated:](_ASHierarchyChangeSet *, BOOL) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/Details/ASDataController.mm:659
#3 0x0000000100211b50 in ::-[ASTableView endUpdatesAnimated:completion:](BOOL, void (^)(BOOL)) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/ASTableView.mm:677
#4 0x0000000100211688 in ::-[ASTableView endUpdates]() at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/ASTableView.mm:662
#5 0x00000001002125e4 in ::-[ASTableView reloadSections:withRowAnimation:](NSIndexSet *, UITableViewRowAnimation) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/ASTableView.mm:738
#6 0x000000010020b220 in ::-[ASTableNode reloadSections:withRowAnimation:](NSIndexSet *, UITableViewRowAnimation) at /Users/testUser/dev/iOSmyApp/Pods/AsyncDisplayKit/AsyncDisplayKit/ASTableNode.mm:584
#7 0x000000010005c318 in __35-[NKLTableNodeController reloadData]_block_invoke at /Users/testUser/dev/iOSmyApp/iOSmyApp/Controllers/NKLTableNodeController.m:114
#8 0x0000000189d9fdfc in +[UIView(Animation) performWithoutAnimation:] ()
#9 0x000000010005c264 in -[NKLTableNodeController reloadData] at /Users/testUser/dev/iOSmyApp/iOSmyApp/Controllers/NKLTableNodeController.m:113
#10 0x000000010005c6ac in -[NKLTableNodeController feedPostsHTTPClient:didReceiveData:] at /Users/testUser/dev/iOSmyApp/iOSmyApp/Controllers/NKLTableNodeController.m:143
#11 0x0000000100063aac in __68-[NKLTablePostsHTTPClient loadPostsWithGroupId:withCount:withOffset:]_block_invoke_2 at /Users/testUser/dev/iOSmyApp/iOSmyApp/Services/NKLTablePostsHTTPClient.m:51
#12 0x0000000100069518 in __116-[AFHTTPSessionManager dataTaskWithHTTPMethod:URLString:parameters:uploadProgress:downloadProgress:success:failure:]_block_invoke.97 at /Users/testUser/dev/iOSmyApp/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m:287
#13 0x000000010008b6bc in __72-[AFURLSessionManagerTaskDelegate URLSession:task:didCompleteWithError:]_block_invoke_2.150 at /Users/testUser/dev/iOSmyApp/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m:308
#14 0x00000001011a1a50 in _dispatch_call_block_and_release ()
#21 0x0000000189df7130 in UIApplicationMain ()
#22 0x0000000100063e3c in main at /Users/testUser/dev/iOSmyApp/iOSmyApp/Application/main.m:14
#23 0x0000000182b4d59c in start ()

@rurza
Copy link

rurza commented May 18, 2017

Bump! I have similar assert on tableView when moving cells (sometimes). I didn't have this issue on earlier versions as I recall.

Basically, I have very simple tablenode in editing mode, with scroll disabled, where one cell isn't move'able (movable?) and need to be at last index.

Stack:

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x0000000182024500 libobjc.A.dylib`objc_exception_throw
    frame #1: 0x00000001835c2eb4 CoreFoundation`+[NSException raise:format:arguments:] + 104
    frame #2: 0x000000018405a720 Foundation`-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 112
    frame #3: 0x00000001009c399c AsyncDisplayKit`::-[ASDisplayNode dealloc](self=0x000000010a2327d0, _cmd="dealloc") at ASDisplayNode.mm:419
    frame #4: 0x0000000100969d24 AsyncDisplayKit`::-[ASCollectionElement .cxx_destruct](self=0x0000000170378f00, _cmd=".cxx_destruct") at ASCollectionElement.mm:24
    frame #5: 0x0000000182022f00 libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
    frame #6: 0x0000000182030334 libobjc.A.dylib`objc_destructInstance + 92
    frame #7: 0x0000000182030398 libobjc.A.dylib`object_dispose + 28
    frame #8: 0x000000018408a2fc Foundation`empty + 72
    frame #9: 0x0000000183fd8c60 Foundation`-[NSConcreteMapTable dealloc] + 60
    frame #10: 0x00000001009ff098 AsyncDisplayKit`-[ASElementMap .cxx_destruct](self=0x000000017044af50, _cmd=".cxx_destruct") at ASElementMap.m:32
    frame #11: 0x0000000182022f00 libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
    frame #12: 0x0000000182030334 libobjc.A.dylib`objc_destructInstance + 92
    frame #13: 0x0000000182030398 libobjc.A.dylib`object_dispose + 28
    frame #14: 0x0000000182042134 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 836
    frame #15: 0x0000000189ee8780 UIKit`__handleEventQueue + 4284
    frame #16: 0x0000000189ee8b9c UIKit`__handleHIDEventFetcherDrain + 148
    frame #17: 0x000000018357142c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
    frame #18: 0x0000000183570d9c CoreFoundation`__CFRunLoopDoSources0 + 540
    frame #19: 0x000000018356e9a8 CoreFoundation`__CFRunLoopRun + 744
    frame #20: 0x000000018349eda4 CoreFoundation`CFRunLoopRunSpecific + 424
    frame #21: 0x0000000184f08074 GraphicsServices`GSEventRunModal + 100
    frame #22: 0x0000000189759058 UIKit`UIApplicationMain + 208
    frame #23: 0x00000001000aac78 Background`main(argc=1, argv=0x000000016fd67948) at main.m:14
    frame #24: 0x00000001824ad59c libdyld.dylib`start + 4
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x0000000182024500 libobjc.A.dylib`objc_exception_throw
    frame #1: 0x00000001835c2eb4 CoreFoundation`+[NSException raise:format:arguments:] + 104
    frame #2: 0x000000018405a720 Foundation`-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 112
    frame #3: 0x00000001009c399c AsyncDisplayKit`::-[ASDisplayNode dealloc](self=0x000000010a2327d0, _cmd="dealloc") at ASDisplayNode.mm:419
    frame #4: 0x0000000100969d24 AsyncDisplayKit`::-[ASCollectionElement .cxx_destruct](self=0x0000000170378f00, _cmd=".cxx_destruct") at ASCollectionElement.mm:24
    frame #5: 0x0000000182022f00 libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
    frame #6: 0x0000000182030334 libobjc.A.dylib`objc_destructInstance + 92
    frame #7: 0x0000000182030398 libobjc.A.dylib`object_dispose + 28
    frame #8: 0x000000018408a2fc Foundation`empty + 72
    frame #9: 0x0000000183fd8c60 Foundation`-[NSConcreteMapTable dealloc] + 60
    frame #10: 0x00000001009ff098 AsyncDisplayKit`-[ASElementMap .cxx_destruct](self=0x000000017044af50, _cmd=".cxx_destruct") at ASElementMap.m:32
    frame #11: 0x0000000182022f00 libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148
    frame #12: 0x0000000182030334 libobjc.A.dylib`objc_destructInstance + 92
    frame #13: 0x0000000182030398 libobjc.A.dylib`object_dispose + 28
    frame #14: 0x0000000182042134 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 836
    frame #15: 0x0000000189ee8780 UIKit`__handleEventQueue + 4284
    frame #16: 0x0000000189ee8b9c UIKit`__handleHIDEventFetcherDrain + 148
    frame #17: 0x000000018357142c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
    frame #18: 0x0000000183570d9c CoreFoundation`__CFRunLoopDoSources0 + 540
    frame #19: 0x000000018356e9a8 CoreFoundation`__CFRunLoopRun + 744
    frame #20: 0x000000018349eda4 CoreFoundation`CFRunLoopRunSpecific + 424
    frame #21: 0x0000000184f08074 GraphicsServices`GSEventRunModal + 100
    frame #22: 0x0000000189759058 UIKit`UIApplicationMain + 208
    frame #23: 0x00000001000aac78 Background`main(argc=1, argv=0x000000016fd67948) at main.m:14
    frame #24: 0x00000001824ad59c libdyld.dylib`start + 4
(lldb) 

code:

#pragma mark - TableNode
- (ASSizeRange)tableView:(ASTableView *)tableView constrainedSizeForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return ASSizeRangeMake(CGSizeMake(self.scrollNode.tableNode.style.preferredSize.width, 70));
}

- (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UIFont *font = [UIFont systemFontOfSize:22 weight:UIFontWeightSemibold];
    UIColor *textColor = [UIColor whiteColor];
    NSDictionary *attributes = @{NSForegroundColorAttributeName: textColor, NSFontAttributeName: font};
    UIEdgeInsets insets = UIEdgeInsetsMake(INFINITY, 15, INFINITY, 15);
    BackgroundScreenNameCellNode *textCellNode = [[BackgroundScreenNameCellNode alloc] initWithAttributes:attributes insets:insets];
    BackgroundScreenType screen = [[GVUserDefaults standardUserDefaults] screenForIndex:indexPath.row];
    if (screen == BackgroundScreenSettings) {
        textCellNode.separatorInset = UIEdgeInsetsMake(INFINITY, INFINITY, INFINITY, 0);
    } else {
        textCellNode.separatorInset = UIEdgeInsetsMake(INFINITY, 15, INFINITY, 0);
    }
    textCellNode.text = [NSString stringForBackgroundScreenType:screen];
    textCellNode.screen = screen;
    textCellNode.backgroundColor = [UIColor clearColor];
    textCellNode.selectionStyle = UITableViewCellSelectionStyleNone;
    return textCellNode;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [GVUserDefaults standardUserDefaults].screensOrder.count;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleNone;
}

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    BackgroundScreenType screen = [[GVUserDefaults standardUserDefaults] screenForIndex:indexPath.row];
    if (screen != BackgroundScreenSettings) {
        return YES;
    }
    return NO;
}

- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
    return NO;
}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
    if (sourceIndexPath.row == destinationIndexPath.row) {
        return;
    }
    NSMutableArray *screensOrder = [[GVUserDefaults standardUserDefaults].screensOrder mutableCopy];
    BackgroundScreenType screen = [[GVUserDefaults standardUserDefaults] screenForIndex:sourceIndexPath.row];
    [screensOrder removeObjectAtIndex:sourceIndexPath.row];
    [screensOrder insertObject:@(screen) atIndex:destinationIndexPath.row];
    [GVUserDefaults standardUserDefaults].screensOrder = screensOrder;
    
    [[NSNotificationCenter defaultCenter] postNotificationName:kScreensOrderDidChanged object:nil userInfo:@{kScreensOrderDidChanged : @0}];//0 gdyż jesteśmy w Ustawieniach
}

- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath
{
    if (proposedDestinationIndexPath.row == [GVUserDefaults standardUserDefaults].screensOrder.count - 1) {
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:([GVUserDefaults standardUserDefaults].screensOrder.count - 2) inSection:proposedDestinationIndexPath.section];
        return indexPath;
    } else {
        return proposedDestinationIndexPath;
    }
}

@appleguy
Copy link
Member

@nguyenhuy @Adlai-Holler although prior manifestations of this issue have occurred, I believe as of the current versions of Texture, the primary issue is the recently-added visibleMap codepath. It's not clear that we are iterating over the items to ensure they are marked invisible.

It may actually be a sufficient fix to keep the map retained for an additional period of time, until removed-from-hierarchy notifications occur. Or, perhaps these are ignored when in the RangeManaged hierarchy state?

screen shot 2017-05-19 at 10 01 55 pm
screen shot 2017-05-19 at 10 01 38 pm

@Adlai-Holler
Copy link
Member

I wish I had more time to address this right now, it's very important to me, but here are some notes for the time being.

  • The current repro project is resolved, so ideally we could get another repro. I bet calling reloadData on ASCollectionNode at the right time would do it. That would explain why Pinterest isn’t seeing it, since we never reloadData.
  • Workaround? It’s very reasonable to suspect that replacing the ASWeakSet in ASRangeController with an NSMutableSet, possibly with the addition of code in ASRangeController dealloc that ensures that those nodes are marked invisible, would keep the issue at bay.
  • A more complete solution to this is probably for UICollectionViewCells to retain their nodes, at least while they’re displaying (before didEndDisplaying: is called).

appleguy added a commit that referenced this issue May 28, 2017
For apps that include pre-existing calls to reloadData, this assertion has made
development difficult on all recent versions of Texture.

Since triggering it can't be reliably used as signal by the app developer, and
halts a development session (sometimes immediately on app start), it should be
disabled until it is reliable again.

See issue #145 for details.
appleguy added a commit that referenced this issue May 29, 2017
#313)

[ASDisplayNode] Revise assertion to log until Issue #145 is addressed. #trivial
bernieperez pushed a commit to AtomTickets/Texture that referenced this issue Apr 25, 2018
…is addressed. (TextureGroup#313)

[ASDisplayNode] Revise assertion to log until Issue TextureGroup#145 is addressed. #trivial
@Adlai-Holler
Copy link
Member

This was indeed resolved by having the range controller retain visible nodes (replacing the weak set as my last comment mentioned.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants