Skip to content

didDisplayNodeContentWithRenderingContext doesn't get called anymore on 2.8.1 vs 2.8 #1680

Closed

Description

@christianselig

Texture version: 2.8.1

I updated from Texture 2.8 to 2.8.1 and didDisplayNodeContentWithRenderingContext isn't getting called anymore. I use that block in the init of a layerBacked ASTextNode to get some custom drawing elements (highlighted elements basically).

I didn't have much time to investigate (iOS 13 time crunch) so I ended up just downgrading back to 2.8 where it works as expected, apologies for not much more information on the issue.

Searching in the Slack for it I see one person had encountered it too:

Does anyone know why didDisplayNodeContentWithRenderingContext block isn't called on ios 13? It gets called on ios 12 (edited)

(I don't believe it's an iOS 13 issue though, it works as expected on iOS 13 if you're using the 2.8 release.)

(Also thanks for all the awesome work the Texture team/contributors have been doing, 2.8.1 packed a ton of awesomeness especially around Dark Mode things, my hats are off to you and I greatly appreciate it!)

Activity

  1. choiks14 commented on Dec 1, 2019

    @choiks14

    same here

  2. christianselig commented on Jul 28, 2020

    @christianselig
    ContributorAuthor

    Here's some super simple sample code showing it not working from a new project.

    Code from Texture 2.8 where didDisplayNodeContentWithRenderingContext does get called:

    class RootViewController: ASViewController<ASDisplayNode> {
        let rootNode = ASDisplayNode()
        let bodyNode = ASTextNode()
    
        init() {
            super.init(node: rootNode)
    
            bodyNode.attributedText = NSAttributedString(string: "Hello, world!", attributes: [.font: UIFont.systemFont(ofSize: 21.0, weight: .semibold), .foregroundColor: UIColor.black])
            rootNode.addSubnode(bodyNode)
    
            bodyNode.didDisplayNodeContentWithRenderingContext = { (context, drawParameters) in
                print("Is this ever called?") // Texture 3.0 never calls this. Texture 2.8 does.
            }
    
            rootNode.layoutSpecBlock = { (node, constrainedSize) in
                return ASCenterLayoutSpec(centeringOptions: .XY, sizingOptions: .minimumXY, child: self.bodyNode)
            }
        }
    
        required init?(coder aDecoder: NSCoder) { fatalError("\(#file) does not implement coder.") }
    }

    However if you change Cocoapods to point to the most recent commit of Texture (3.0) (and change the code sample to subclass ASDKViewController and change init() to override init()), you'll see didDisplayNodeContentWithRenderingContext will no longer get called.

    This changes if you change from ASTextNode to ASTextNode2 (didDisplayNodeContentWithRenderingContext will get called) however ASTextNode2 is still missing a lot of helpful methods from ASTextNode like rectsForTextRange which prevents me from migrating over to it fully (in fact in my real project I use didDisplayNodeContentWithRenderingContext and rectsForTextRange together so it's even more important, haha).

  3. christianselig commented on Jul 28, 2020

    @christianselig
    ContributorAuthor

    Ready for some Rube Goldberg magic? Issue seems to be that at some point between 2.8 and 3.0:

    • ASTextNode (not ASTextNode2) added the displayWithParameters:isCancelled: method (you can see here)
    • Which causes flags.implementsImageDisplay to be YES.
    • This in turn causes shouldCreateGraphicsContext in ASDisplayNode+AsyncDisplay to be set to NO.
    • Which in turns causes the graphics context to never be created, so it's nil.
    • Slightly further down in the method that implements the block callback it's required that the graphics context be non-nil in order to call the callback. Since it's nil it just skips right past it and the block never gets called.

    Note that ASTextNode2 on the other hand does not implement displayWithParameters:isCancelled:, so flags.implementsImageDisplay is NO which causes everything to be set up properly.

    I'm admittedly not sure what the obvious fix is here or why ASTextNode implements that method while ASTextNode2 does not. For now I just reverted the ASTextNode.mm file to the 2.8 version and all works again on my end.

  4. self-assigned this
    on Aug 5, 2020
  5. garrettmoon commented on Aug 5, 2020

    @garrettmoon
    Member

    @christianselig thank you for the thorough investigation!

  6. added a commit that references this issue on Aug 5, 2020
    b3b8705
  7. added a commit that references this issue on Sep 15, 2020
    5259789
  8. added 2 commits that reference this issue on Dec 24, 2021
    2796c8e
    b887cd1
  9. added a commit that references this issue on Mar 22, 2024
    afc1261
  10. added a commit that references this issue on Apr 4, 2026
    8dcb3b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions