shaps80 / SwiftUIBackports

A collection of SwiftUI backports for iOS, macOS, tvOS and watchOS
MIT License
931 stars 59 forks source link

Infinite loop in UIView parentController property on iOS 14.0-14.4 #23

Closed anivaros closed 1 year ago

anivaros commented 1 year ago

General Information

See attached project

Describe the bug

Uninited tab body causes infinite loop in UIView parentController property

Steps to reproduce

  1. Run attached project on iOS 14.0-14.4
  2. Tap "Show modal" on tab A
  3. Select TextField

Expected behavior

No infinite loop in OwningController.swift

Stack trace, compiler error, code snippets

Archive.zip

Additional context

If tab B were opened before Modal, all works fine.

shaps80 commented 1 year ago

Thank you for raising, will investigate 👍🏻

anivaros commented 1 year ago

This issue could occur in other scenarios, but this is simplest way to reproduce

ChristopherCarranza commented 1 year ago

Just ran into this as well with a TabView. Thank you for looking into it.

shaps80 commented 1 year ago

I'm having trouble getting this issue to show up tbh. I've used your project and explored this myself but I cannot reproduce. Are you able to reproduce 100% of the time?

You mention above that the issue occurs in Xcode 13, but you saved the project using Xcode 14 beta, so I fixed that and tried in 13 but still no joy.

anivaros commented 1 year ago

Yes, 100%. Same problem on Xcode 14, no difference. Which simulator did you use? Just checked on Xcode 14 RC + iPhone 11 14.1, same problem.

Screenshot 2022-09-12 at 11 23 25
shaps80 commented 1 year ago

Ok I'll try that, odd that its not 100% of the time for me. Thanks for checking, will try this now.

anivaros commented 1 year ago

I've got same problem on latest iOS with .backport.scrollDisabled(true) on code like this:

ScrollView {
    LazyVGrid(columns: [GridItem(.adaptive(minimum: 140))]) {
        rows
    }
}
.backport.scrollDisabled(true)

But I can't achieve this on minimal reproducible example :(

shaps80 commented 1 year ago

Yeah I'm guessing its an issue in the view controller lookup code, I think I have an idea for fixing it overall.

shaps80 commented 1 year ago

@anivaros I should have a new release out today/tomorrow that I think resolves this issue completely.

anivaros commented 1 year ago

Great news! 🔥

shaps80 commented 1 year ago

FYI I’ve fallen sick today, will get to this very soon, just need a couple days 👍🏻

anivaros commented 1 year ago

Oh! Get well soon!

shaps80 commented 1 year ago

@anivaros the fix should now be in main – if you could check it out and confirm it resolves the issues you've been seeing that'd be great, if so, I can merge in just that change and make a release – thanks!

anivaros commented 1 year ago

.@shaps80 I've checked, now all ok. Also checked issue with .backport.scrollDisabled(true) and LazyVGrid. Looks like now all works as expected 🎉 Thank you!!

shaps80 commented 1 year ago

Amazing! Glad to hear. I'll get this in shortly :)

X901 commented 1 year ago

This not working I tried it with ScrollView with LazyVStack also with List it didn't disable Scrolling !

shaps80 commented 1 year ago

You’ll need to provide a failing demo project to be helpful here.

Also please create a new issue since this is slightly unrelated to initial issue and this was resolved, thanks.