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

Remove manual task clearing in URLSessionClient invalidate #1443

Merged
merged 1 commit into from
Oct 16, 2020

Conversation

philfi
Copy link
Contributor

@philfi philfi commented Oct 8, 2020

This resolves assertion crashes that are still occurring as described in this issue #1376 (comment) despite the fix introduced in #1383.
In theory since URLSession.shared is not being used, there shouldn't be a need for any manual task clearing. In my testing calling invalidateAndCancel prior to cleaning up tasks seems to consistently do the trick.

URLSession.shared is not being used, calling invalidateAndCancel prior to cleaning up tasks works.
@apollo-cla
Copy link

@philfi: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@designatednerd
Copy link
Contributor

The problem is that while we're not using urlSession.shared directly, we're still passing in the shared config, which means in most cases I believe that generally winds up having the same problem as actually using the shared session.

That said, if you want to break it out so that the manual cancellation only happens when the shared session config is the config, that could probably work.

@philfi
Copy link
Contributor Author

philfi commented Oct 9, 2020

ah had missed that the URLSessionConfiguration.default was being used as a default argument, thanks for pointing that out.

I'll do some testing with that case to get familiar but my hope is this logic should cover both that and the case of an injected config, which pretty consistently triggers this assertion failure for me at least. Will also take a look into the test failures on macOS, had them passing locally running 10.15.4.

@designatednerd
Copy link
Contributor

I wouldn't worry too much about the test failures, the tests that are failing are flaky as hell

@designatednerd
Copy link
Contributor

@philfi Have you had a chance to try to update this or do you mind if I take it over?

@philfi
Copy link
Contributor Author

philfi commented Oct 15, 2020

@designatednerd apologies I have not, feel free to take it over!

@designatednerd
Copy link
Contributor

Ooh! OK so working on this when I set it up to do the extra work if session.configuration == URLSessionConfiguration.default was true, the work got done. BUT when I set it up for session == URLSession.shared, it was never hit.

The docs for invalidateAndCancel say:

Calling this method on the session returned by the sharedSession method has no effect.

So I think your approach is actually the correct one, and we don't need to bother with manual task cancellation. Poking CI, will merge if it passes.

@designatednerd designatednerd added this to the Next Release milestone Oct 16, 2020
@designatednerd designatednerd merged commit 94fcd28 into apollographql:main Oct 16, 2020
@philfi
Copy link
Contributor Author

philfi commented Oct 16, 2020

Thanks @designatednerd!

@RolandasRazma
Copy link
Contributor

Just FIY still happening in 0.36.0 (iOS12 simulator)

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.

4 participants