Addressing App Crashes Due to Locked Files in Shared Containers on Background Transition

Hi everyone,

I'm facing a critical issue with my app crashing when it goes into the background, and I'm hoping to find some advice or solutions from this knowledgeable community. My app utilizes a shared directory between itself and a FileProvider, alongside tdlib, which includes SQLite. The logic to work with tdlib is housed within a shared framework, which necessitates access to certain files by both the App and FileProvider.

However, when I minimize the app, it crashes and logs the following error:

[app<com.sedoyjan.keepgram(74B4C997-E6C2-4B65-8A31-CA1809248B01)>:3941] Terminating with context: <RBSTerminateContext| domain:15 code:0xDEAD10CC explanation:[app<com.sedoyjan.keepgram(74B4C997-E6C2-4B65-8A31-CA1809248B01)>:3941] was suspended with locked system files:
/var/mobile/Containers/Shared/AppGroup/1F13B8D2-EC11-465C-85DE-2ED8797C5DF0/td/db.sqlite
/var/mobile/Containers/Shared/AppGroup/1F13B8D2-EC11-465C-85DE-2ED8797C5DF0/td/td.binlog
not in allowed directories:
/var/mobile/Containers/Data/Application/8C035881-2676-4B92-A9AB-51A664D541C8
/var/mobile/Containers/Data/Application/8C035881-2676-4B92-A9AB-51A664D541C8/tmp reportType:CrashLog maxTerminationResistance:Absolute>

This error suggests that the app is terminated due to having locked files within the shared container, which aren't allowed when the app is suspended.

My question to the community is: Is there a way to keep the app running in the background without running into this issue with locked files in the shared container? Are there specific practices or architectural changes I should consider to prevent these crashes?

Any advice, insights, or suggestions would be greatly appreciated as I navigate this challenge. Thank you in advance for your help!

See also:

https://developer.apple.com/forums/thread/747163?answerId=780826022

No solution there, but it's the same problem.

Addressing App Crashes Due to Locked Files in Shared Containers on Background Transition
 
 
Q