react-native-background-downloader icon indicating copy to clipboard operation
react-native-background-downloader copied to clipboard

fix: Move iOS session init at download start into the synchronised block to avoid using invalidated session

Open vinicz opened this issue 4 years ago • 4 comments

Hi!

We had a couple of crash reports with this error:

SIGABRT: Task created in a session that has been invalidated

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.

vinicz avatar Jan 07 '21 11:01 vinicz

Hi, thanks for this change. We needed it to stop some crashes on our app too. @ptelad would it be possible to merge this?

aceew avatar Apr 01 '21 09:04 aceew

@aceew any plans of merging it? I did a PR too ( #113 ) but this one looks a bit better.

Anyways, we really need to fix this out!

sidferreira avatar May 19 '21 00:05 sidferreira

@aceew any plans of merging it? I did a PR too ( #113 ) but this one looks a bit better.

Anyways, we really need to fix this out!

I'm not a maintainer unfortunately so I don't have permission to merge or release. I approved as we had tested the fix for our app and confirmed it worked.

aceew avatar May 19 '21 00:05 aceew

@aceew bummer... Starting to feel like this project was abandoned...

sidferreira avatar May 19 '21 02:05 sidferreira