This repository has been archived by the owner on Sep 25, 2021. It is now read-only.
Make sure finishRequest() is always called for cold boot visits #154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello and thanks for a great framework!
In a Turbolinks app I'm currently working on, we display multiple navigation controllers in a tab bar controller. Each navigation controller has their own
Session
but share the sameWKProcessPool
.When showing and hiding the network activity indicator in response to receiving
sessionDidStartRequest(_:)
andsessionDidEndRequest(_:)
messages, I found thatsessionDidEndRequest(_:)
wasn't called if I switched to a different tab before the request hda finished. Since we're using reference counting to show and hide the indicator, this caused the indicator to never be hidden.In 11d71c3, I have made some changes that make this easier to reproduce: just start the demo app, switch to the second tab, and watch the printed messages in the Xcode debugger output pane.
We should make sure to remove this commit before merging if you decide doing so makes sense.
The reason
sessionDidEndRequest(_:)
isn't called is the theWKWebView
won't send thewebView(_:didFinish:)
message to itsnavigationDelegate
(i.e. theColdBootVisit
) after switching to a different tab. I don't know why it doesn't do so and can't find any documentation describing this behavior.In 4515ceb, I add a call to
finishRequest()
inColdBootVisit.completeVisit()
to fix this problem. SincefinishRequest()
only callssessionDidEndRequest(_:)
once and we know that the request must have finished at this point I think this should be safe.Let me know what you think!