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

iOS 16: App freezes and hangs when trying to build WrappingHStack content #29

Closed
SetSailSwift opened this issue Oct 8, 2022 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@SetSailSwift
Copy link

Describe the bug
When scrolling through items that contain a WrappingHStack instance in the component, our app freezes but never crashes. This is due to the main thread getting clogged up when trying to create a WrappingHStack for our component.

To Reproduce
Use a WrappingHStack instance in component, adding that component into a scroll view.
Try to scroll through items on iOS 16 device.

Expected behavior
Should be able scroll through feed without freezing.

Screenshots
Thread Capture
Screen Shot 2022-10-08 at 2 06 10 PM

Line in InternalWrappingHStack that appears to be clogging thread:
Screen Shot 2022-10-08 at 2 06 26 PM

In the below give, the tags in each card is contained in a WrappingHStack instance:
Flave-Daily-Deals-freezeNcrash

Context:

  • WrappingHStack version: 2.2.1
  • Model: All
  • OS: iOS 16.0.2

Additional context
Appears to be related to issues #27 & #28.

@SetSailSwift SetSailSwift added bug Something isn't working help wanted Extra attention is needed labels Oct 8, 2022
@dkk dkk removed their assignment Oct 12, 2022
@x-sheep
Copy link

x-sheep commented Oct 13, 2022

This happens to me as well. I had the WrappingHStack in a ScrollView, and when it scrolled into view the app froze entirely. Since iPadOS does not yet have an upgrade to 16 available, it works fine on iPads but not iPhones.

Repository owner deleted a comment from theedov Oct 17, 2022
@SetSailSwift
Copy link
Author

@dkk are you still supporting this package? I saw in #27 it affects v2.2.2 as well but noticed you are removing yourself from the assignments. I just wanted to clarify if the iOS 16 issue would be looked at in the future or if I'll need to pivot to another solution for now. Thanks!

@x-sheep
Copy link

x-sheep commented Oct 17, 2022

iOS 16 has introduced the Layout protocol. If fixing the current implementation for iOS 16 isn't working out, it may be worth considering reimplementing the WrappingHStack using the new system, then conditionally switching back to the old system using if #available blocks based on the user's iOS version.

https://developer.apple.com/documentation/swiftui/custom-layout

@dkk
Copy link
Owner

dkk commented Oct 17, 2022

@SetSailSwift I'm still supporting, but currently I don't have a lot of spare time. I am removing my assignments to let anyone willing to help know that there are issues and that nobody is working on them at the moment.

@SetSailSwift
Copy link
Author

@dkk Understood. Thanks for clarifying!

@MikeMorawski
Copy link
Contributor

It looks like its an issue with let itemWidth = hostingController.view.intrinsicContentSize.width as this line specifically will cause a never ending reinitialization.

The loop only occurs when a parent GeometryReader geo.frame(in: .global) reference, which continues the feedback loop, as is the case with it required in WrappingHStack.

@MikeMorawski
Copy link
Contributor

One last note, it looks like swapping from intrinsicContentSize to sizeThatFits does not cause the feedback loop, but not sure exactly how to fit that into the current solution just yet.

Repository owner deleted a comment from gabriel Oct 18, 2022
@dkk
Copy link
Owner

dkk commented Oct 19, 2022

Closing for now, if you still have this issues 2.2.3, please reopen.

@dkk dkk closed this as completed Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants