You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
didDisplayNodeContentWithRenderingContext doesn't get called anymore on 2.8.1 vs 2.8 #1680
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!)
Here's some super simple sample code showing it not working from a new project.
Code from Texture 2.8 where didDisplayNodeContentWithRenderingContextdoes get called:
classRootViewController:ASViewController<ASDisplayNode>{letrootNode=ASDisplayNode()letbodyNode=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)inprint("Is this ever called?") // Texture 3.0 never calls this. Texture 2.8 does.
}
rootNode.layoutSpecBlock ={(node, constrainedSize)inreturnASCenterLayoutSpec(centeringOptions:.XY, sizingOptions:.minimumXY, child:self.bodyNode)}}requiredinit?(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 (didDisplayNodeContentWithRenderingContextwill 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).
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.
Activity
choiks14 commentedon Dec 1, 2019
same here
christianselig commentedon Jul 28, 2020
Here's some super simple sample code showing it not working from a new project.
Code from Texture 2.8 where
didDisplayNodeContentWithRenderingContextdoes get called:However if you change Cocoapods to point to the most recent commit of Texture (3.0) (and change the code sample to subclass
ASDKViewControllerand changeinit()tooverride init()), you'll seedidDisplayNodeContentWithRenderingContextwill no longer get called.This changes if you change from
ASTextNodetoASTextNode2(didDisplayNodeContentWithRenderingContextwill get called) howeverASTextNode2is still missing a lot of helpful methods fromASTextNodelikerectsForTextRangewhich prevents me from migrating over to it fully (in fact in my real project I usedidDisplayNodeContentWithRenderingContextandrectsForTextRangetogether so it's even more important, haha).christianselig commentedon Jul 28, 2020
Ready for some Rube Goldberg magic? Issue seems to be that at some point between 2.8 and 3.0:
ASTextNode(notASTextNode2) added thedisplayWithParameters:isCancelled:method (you can see here)flags.implementsImageDisplayto beYES.shouldCreateGraphicsContextin ASDisplayNode+AsyncDisplay to be set toNO.nil.Note that
ASTextNode2on the other hand does not implementdisplayWithParameters:isCancelled:, soflags.implementsImageDisplayisNOwhich causes everything to be set up properly.I'm admittedly not sure what the obvious fix is here or why
ASTextNodeimplements that method whileASTextNode2does not. For now I just reverted theASTextNode.mmfile to the 2.8 version and all works again on my end.garrettmoon commentedon Aug 5, 2020
@christianselig thank you for the thorough investigation!
Call will / did display node for ASTextNode. Fixes TextureGroup#1680
Merge branch 'releases/p8.35'
[Accessibility] Ship ASExperimentalDoNotCacheAccessibilityElements (T…
[Accessibility] Ship ASExperimentalDoNotCacheAccessibilityElements (T…
Call will / did display node for ASTextNode. Fixes TextureGroup#1680 (T…
Call will / did display node for ASTextNode. Fixes TextureGroup#1680 (T…