braze-inc / braze-swift-sdk

Braze SDK for the Apple ecosystem, including: iOS, macOS, iPadOS, visionOS, tvOS
https://www.braze.com
Other
52 stars 19 forks source link

[Bug]: BackgroundTask running might cause terminate the app #36

Closed LucioPham closed 1 year ago

LucioPham commented 1 year ago

Platform

iOS

Platform Version

iOS 16.1.1

Braze SDK Version

5.9.0

Xcode Version

Xcode 14.2

Computer Processor

Apple (M1)

Repro Rate

100%

Steps To Reproduce

I did upgrade to the latest version with the minimum migration from Appboy-SDK.

When running the app then put it into the background and then back again to the foreground (sometimes don't need to back to the foreground ) then I got the log from the Xcode console as below.

[BackgroundTask] Background Task 15021 ("http.client: POST /data"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

This issue might cause my app getting to terminate by iOS System.

I'm trying to disable BrazeSDK and never got the log again and my app never gets terminated by iOS System when it is in the background.

I suppose this background task has come from BrazeSDK. Please help me to check on this. Thanks

Expected Behavior

Not receiving the warning log as below from the console when using BrazeSDK

[BackgroundTask] Background Task 15021 ("http.client: POST /data"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

Actual Incorrect Behavior

Keep receiving the warning log from the console when using BrazeSDK.

[BackgroundTask] Background Task 15021 ("http.client: POST /data"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

Verbose Logs

[BackgroundTask] Background Task 15021 ("http.client: POST /data"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

Additional Information

No response

lowip commented 1 year ago

Hi @LucioPham,

We are able to reproduce the issue, and we'll release a fix for it soon. We'll post an update on this thread once that release is available.

LucioPham commented 1 year ago

Hi @lowip , Thank you for your quick response and support.

Just FYI, today when I tried to run my app I also got the log related to the Background task as below as well.

[33307:11893997] [BackgroundTask] Background Task 1089 ("http.client: POST /content_cards/sync"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

hokstuff commented 1 year ago

Hi @LucioPham,

We have released version 5.9.1 which should fix this issue - let us know if you run into any problems. Thanks!

LucioPham commented 1 year ago

Hi @hokstuff @lowip , I did some testing around the new version 5.9.1 but still running into this issue but with more log as below.

[BackgroundTask] Background Task 954 ("http.client: POST /data"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

[BackgroundTask] Background Task 684 ("persistence: users/user_id/news-feed"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

Please help me check this issue. Thank you.

LucioPham commented 1 year ago

Hello @hokstuff @lowip , this issue still happens and is more usual, please help to take a look. Thanks.