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

DispatchQueue with Background QoS has long delay #2321

Closed
2 tasks done
nnnlog opened this issue Oct 3, 2024 · 1 comment
Closed
2 tasks done

DispatchQueue with Background QoS has long delay #2321

nnnlog opened this issue Oct 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@nnnlog
Copy link
Contributor

nnnlog commented Oct 3, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

In the iOS, first-time loaded page is very slow to complete load(generally DOMContentLoaded).

public func onReceivedServerTrustAuthRequest(challenge: ServerTrustChallenge, callback: ReceivedServerTrustAuthRequestCallback) {
if channel == nil {
callback.defaultBehaviour(nil)
return
}
// workaround for ProtectionSpace.toMap() SSL Certificate
// https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678
DispatchQueue.global(qos: .background).async {
let arguments = challenge.toMap()
DispatchQueue.main.async { [weak self] in
if self?.channel == nil {
callback.defaultBehaviour(nil)
return
}
self?.channel?.invokeMethod("onReceivedServerTrustAuthRequest", arguments: arguments, callback: callback)
}
}
}

It seems like to DispatchQueue with Background QoS has long delay. I just printed log in Line 998 (before queue), and Line 1003 (in queue). In some cases, the time between the two logs being output was as long as one minute.

Expected Behavior

It should be execute (almost) immediately, still not affecting main thread.

Steps with code example to reproduce

It is very difficult to reproduce issue but it occurs explicitly.

  1. Prepare the device with cleaned iOS. (In Simulator, you can reproduce this behavior with Device -> Erase all content ...)
  2. Load any page with HeadlessInAppWebView. (I don't verify that this issue can be produced by general webview instance)
  3. In first loading, there is too many times to load page including assets such as css/js/image, etc.

Stacktrace/Logs

There is no stacktrace, but attach some logs for debugging.

WebView Console (Safari Technology Preview)
image
image

Flutter version

v3.26.0-0.1.pre

Operating System, Device-specific and/or Tool

iOS 18

Plugin version

v6.1.4

Additional information

I have commit (nnnlog@6a0c192) already. I write this issue for opening PR.

Self grab

  • I'm ready to work on this issue!
@nnnlog nnnlog added the bug Something isn't working label Oct 3, 2024
@nnnlog nnnlog closed this as completed Nov 2, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant