Texture icon indicating copy to clipboard operation
Texture copied to clipboard

ASScrollNode > automaticallyManagesContentSize causes issues with Node sizes

Open 0xTomTom opened this issue 5 years ago • 5 comments

Hi there

Issue I am having issues with Nodes not showing up in my ASScrollNode when running on a physical device. This project exists for a while and ran fine on Xcode v11, iOS 13 and before. This issue does not occur on a Simulator, only on a physical device.

My Specs Xcode Version 12.0.1 (12A7300) Texture 3.0.0

Running on: iOS 14.0.1

My Code I am instantiating a ASDKViewController<ASScrollNode> and configuring the ASScrollNode:

override init() {
    super.init(node: mainNode)
    setMainNode()
  }

private func setMainNode() {
    mainNode.automaticallyManagesSubnodes = true
    mainNode.automaticallyRelayoutOnSafeAreaChanges = true
    mainNode.automaticallyManagesContentSize = true
    if #available(iOS 13.0, *) {
      mainNode.view.automaticallyAdjustsScrollIndicatorInsets = false
    }
    mainNode.backgroundColor = Style.ColorStyle.viewBackground.color
    mainNode.layoutSpecBlock = { [weak self] node, size in
      guard let strongSelf = self else { return ASLayoutSpec() }
      let contentStack = ASStackLayoutSpec(direction: .vertical, spacing: 8, justifyContent: .start, alignItems: .start, children: [strongSelf.myObjectsButton, strongSelf.staticsHeaderNode])
      if let statistics = strongSelf.statics {
        contentStack.children!.append(contentsOf: statistics.nodes)
      }
      contentStack.style.preferredLayoutSize.height = .max
      contentStack.style.preferredLayoutSize.width = .max
      let contentInsets = ASInsetLayoutSpec(insets: UIEdgeInsets(top: 0, left: 16, bottom: 200, right: 16), child: contentStack)
      contentInsets.style.preferredLayoutSize = ASLayoutSize(width: .max, height: .max)
      let contentBackground = ASBackgroundLayoutSpec(child: contentInsets, background: strongSelf.statisticsBackground)
      let finalContent = ASStackLayoutSpec(direction: .vertical, spacing: 8, justifyContent: .start, alignItems: .start, children: [strongSelf.header, contentBackground])
      finalContent.style.preferredLayoutSize.width = .max
      return ASInsetLayoutSpec(insets: UIEdgeInsets(top: node.safeAreaInsets.top, left: 0, bottom: 0, right: 0), child: finalContent)
    }
  }

This renders the view fine on a simulator. However, when running on a device, the statistics.nodes don't show. Playing around with the scroll node, the issue of the 'not showing' nodes resolves when I comment out, or not set:

mainNode.automaticallyManagesContentSize = true

This causes another issue, that my view's contentSize is set to zero, but the nodes do show. Not sure what's going wrong in this version of Texture.

Screenshots of the simulator and device, running the same code:

Simulator screenshot

Simulator Screen Shot - iPhone 11 Pro - 2020-10-05 at 11 39 56

Device

IMG_EBF034DC59A0-1

0xTomTom avatar Oct 05 '20 09:10 0xTomTom

Posting here because we've seen this issue as well. Seems to happen since iOS 14, and in our case it only happens on optimized builds

JohnEstropia avatar Oct 06 '20 07:10 JohnEstropia

We have worked around this for now by forcing Texture to build with no optimizations:

# Podfile

# ...

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|

            # remove when this issue is fixed: https://github.com/TextureGroup/Texture/issues/1926
            if 'Texture' == target.name
              config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
            end

        end
    end
end

JohnEstropia avatar Oct 06 '20 10:10 JohnEstropia

We have worked around this for now by forcing Texture to build with no optimizations:

# Podfile

# ...

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|

            # remove when this issue is fixed: https://github.com/TextureGroup/Texture/issues/1926
            if 'Texture' == target.name
              config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
            end

        end
    end
end

Great workaround for now, thanks! Optimization shouldn't change the modules behaviour though. iOS 14 bug rather then a Texture bug?

0xTomTom avatar Oct 07 '20 07:10 0xTomTom

We have worked around this for now by forcing Texture to build with no optimizations:

# Podfile

# ...

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|

            # remove when this issue is fixed: https://github.com/TextureGroup/Texture/issues/1926
            if 'Texture' == target.name
              config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
            end

        end
    end
end

this one save my project

hungwei0331 avatar Dec 02 '20 03:12 hungwei0331

Maybe, I can investigate this issue if I get a small project which reproduces this issue.

muukii avatar Jun 03 '21 03:06 muukii