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

Fix infinite loop caused by URL loading #1

Merged
merged 5 commits into from May 15, 2024
Merged

Fix infinite loop caused by URL loading #1

merged 5 commits into from May 15, 2024

Conversation

Kyome22
Copy link
Collaborator

@Kyome22 Kyome22 commented Apr 23, 2024

Loads the argument URL received during WebView initialization only once.

How to reproduce the issue.

ContentViewState.swift

- let requestURL = URL(string: "https://cybozu.github.io/webview-debugger")!
+ let requestURL = URL(string: "https://www.google.com")!

ContentView.swift

WebViewReader { proxy in
    VStack {
        // ...

-       WebView(configuration: viewState.configuration)
+       WebView(url: viewState.requestURL, configuration: viewState.configuration)
            .uiDelegate(viewState)
            .navigationDelegate(viewState)
            .allowsInspectable(true)
            .allowsBackForwardNavigationGestures(true)
            .allowsLinkPreview(false)
            .refreshable()
            .border(Color.gray)
    }
-   .onAppear {
-       proxy.load(url: viewState.requestURL)
-   }
+   // .onAppear {
+   //     proxy.load(url: viewState.requestURL)
+   // }
}

@ichiho-ojima
Copy link
Collaborator

We would like to use testing to ensure that the infinite loop issue does not occur.
Is it possible to guarantee this with a unit test?

@Kyome22
Copy link
Collaborator Author

Kyome22 commented May 14, 2024

We would like to use testing to ensure that the infinite loop issue does not occur. Is it possible to guarantee this with a unit test?

It would be difficult to write an unit test that runs ViewRepresentable's updateUIView() method.
Therefore, it seems impossible to reproduce the infinite loop in the unit test.

@ichiho-ojima
Copy link
Collaborator

It would be difficult to write an unit test that runs ViewRepresentable's updateUIView() method. Therefore, it seems impossible to reproduce the infinite loop in the unit test.

Understood. I have come to the same conclusion.
Thanks.

Copy link
Collaborator

@ichiho-ojima ichiho-ojima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Kyome22 Kyome22 merged commit fcd0ec4 into main May 15, 2024
1 check failed
@Kyome22 Kyome22 deleted the fix-infinite-loop branch May 15, 2024 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants