This repository has been archived by the owner on Feb 27, 2022. It is now read-only.
fix: Move iOS session init at download start into the synchronised block to avoid using invalidated session #98
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.
Hi!
We had a couple of crash reports with this error:
After a bit of investigation, we found that a potential cause of the issue (although it's really hard to reproduce) is that at the download start the initialization of the session is outside of the synchronized block, which could lead to that it could get a session that's invalidated in the meantime because of concurrently finishing tasks. This matches what we saw in the logs as our users started a lot of concurrent downloads, they canceled the tasks (this is an asynchronous action), and soon after that (in a minute) they started again a bunch of tasks. If the cancels just finished when the new downloads are started this could lead to the situation of getting an invalidated session.
We tested this solution and looks working but it's not yet in production and as I mentioned as we cannot reproduce the original crash, so it's not 100% that this PR fixed the issue, but we still think that this could be at least a fix for some cases.
Let me know what do you think.