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

[BUG] Still Crashes on 4.0.0 pre iOS 17 #162

Closed
bukira opened this issue Nov 18, 2024 · 16 comments · Fixed by #168
Closed

[BUG] Still Crashes on 4.0.0 pre iOS 17 #162

bukira opened this issue Nov 18, 2024 · 16 comments · Fixed by #168
Assignees

Comments

@bukira
Copy link

bukira commented Nov 18, 2024

Updated to 3.0.0 and 4.0.0 and the popup still crashes for iOS 16 and below

iOS 17 and iOS 18 work fine

// MARK: Popup Height
extension ViewModel {
    func updatePopupHeight(_ heightCandidate: CGFloat, _ popup: AnyPopup) async {
        guard activePopupProperties.gestureTranslation == 0 else { return }

        let newHeight = await calculatePopupHeight(heightCandidate, popup)
        if newHeight != popup.height {
            await updatePopupAction(popup.updatedHeight(newHeight))
        }
    }
}

Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

crashes on the line:
await updatePopupAction(popup.updatedHeight(newHeight))

for centre and bottom popups

Printing description of newHeight:
0.0
Printing description of heightCandidate:
319.0
Printing description of popup.height:
nil

Same popus didnt crash pre 3.0.0

@FulcrumOne
Copy link
Contributor

Hey @bukira,

Thanks for letting me know. Could you please show me the part of the code where you call the .registerPopups() method, as a similar issue was recently created (#158) and I wonder if this is somehow related.

Thanks again for your help,
Tomasz

@bukira
Copy link
Author

bukira commented Nov 18, 2024

Yes certainly

 var body: some Scene {
        WindowGroup {
            RootView()
                .registerPopups()
                .logRender("RootView")
        }
        .onChange(of: phase) { newPhase in
            switch newPhase {
            case .active:
                activePhase() //App became active
            case .inactive:
                inactivePhase() //App became inactive
            case .background:
                backgroundPhase() //App is running in the background no UI
            @unknown default: break
                //Fallback for future cases
            }
        }
    }
@main
struct App: App {
    
    @Environment(\.scenePhase) private var phase
    
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    
    init() {
        setupFirebase()
        setupConfig()
        setupDependencies()
        setupAppearance()
        setupPageControl()
    }
    
    var body: some Scene {
        WindowGroup {
            RootView()
                .registerPopups()
                .logRender("RootView")
        }
        .onChange(of: phase) { newPhase in
            switch newPhase {
            case .active:
                activePhase() //App became active
            case .inactive:
                inactivePhase() //App became inactive
            case .background:
                backgroundPhase() //App is running in the background no UI
            @unknown default: break
                //Fallback for future cases
            }
        }
    }
}

@FulcrumOne
Copy link
Contributor

FulcrumOne commented Nov 18, 2024

@bukira, could you, for testing purposes comment out @Environment(`.scenePhase) private var phase and see if the crash still occurs? If not, I think I know how I can fix it

@bukira
Copy link
Author

bukira commented Nov 18, 2024

doesnt crash with that commented out

@FulcrumOne
Copy link
Contributor

Great. I mean not great, but at least I know how to fix it. I will provide you with a solution in a moment.

@bukira
Copy link
Author

bukira commented Nov 18, 2024

awesome and yeah great if we know the cause and super awesome for such a quick response :-)

@FulcrumOne
Copy link
Contributor

Could you check if the patch-4.0.1 branch solves your problem?

@bukira
Copy link
Author

bukira commented Nov 18, 2024

Your the man, that fixed it cheers

@FulcrumOne
Copy link
Contributor

Haha, glad to hear that. Unfortunately, I'll have to do some additional testing before this goes public, as there were reasons why I wanted to avoid such a solution 😅

Have a nice day @bukira!

@wwzzyying
Copy link

image

Hi FulcrumOne, I also got this crash with iOS17, my registerPopups just like this.

image

@FulcrumOne
Copy link
Contributor

Hey,

Did you try that branch? Thanks

@wwzzyying
Copy link

I just tried it, and it really doesn't crash.

@kevinobssuth
Copy link

kevinobssuth commented Nov 23, 2024

hey man. I am finding that first crash from the first comment on here on iOS 18

edit - for visibility, used the patch branch and it resolved this on iOS 18

@Vincz
Copy link

Vincz commented Nov 24, 2024

I do have the same issue at the same line on macOS.
I'm trying to attach the .registerPopups to a view (note that I don't use Scene my windows are created manually and View injected through NSHostingView).

@FulcrumOne
Copy link
Contributor

Did you try the branch patch-4.0.1?

@Vincz
Copy link

Vincz commented Nov 24, 2024

Did you try the branch patch-4.0.1?

Just tried. It works perfectly 😄

@FulcrumOne FulcrumOne linked a pull request Dec 19, 2024 that will close this issue
@FulcrumOne FulcrumOne moved this to In review in Popups Roadmap Dec 19, 2024
@FulcrumOne FulcrumOne self-assigned this Dec 19, 2024
@FulcrumOne FulcrumOne mentioned this issue Dec 19, 2024
FulcrumOne added a commit that referenced this issue Dec 19, 2024
fix:
- Fixed a bug caused by the user declaring a value that caused the entire WindowGroup to be updated (#162)
@github-project-automation github-project-automation bot moved this from In review to Done in Popups Roadmap Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants