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

Crash on Apple TV device #177

Closed
dannyhuggins opened this issue Feb 23, 2022 · 13 comments · Fixed by #180
Closed

Crash on Apple TV device #177

dannyhuggins opened this issue Feb 23, 2022 · 13 comments · Fixed by #180
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@dannyhuggins
Copy link

dannyhuggins commented Feb 23, 2022

Describe the bug
I am getting an app crash when using the SDK on a physical Apple TV device. I get the following error when the SDK is attempting to create the CrowdinFolder for the translation files:

Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "Crowdin" in the folder ".Crowdin"."

Note that this does not happen on the Apple TV simulator in Xcode, only a physical device.

To Reproduce
Steps to reproduce the behavior:

  1. Build to a physical Apple TV device
  2. The app crashes after starting the CrowdinSDK

Expected behavior
My understanding is that storing data on an Apple TV is not available outside of the cache directory, and when the SDK attempts to create a folder in the documents directory, the FileManager throws an exception.

Screenshots
Screen Shot 2022-02-22 at 6 49 22 PM

Smartphone (please complete the following information):

  • Device: Apple TV 4K (2nd generation)
  • OS: tvOS 15.3

Additional context
I was able to avoid the crash by changing DocumentsFolder.documentsPath from:
static let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
to:
static let documentsPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)[0]
but I am not aware if this will have any performance implications.

@dannyhuggins dannyhuggins added the bug Something isn't working label Feb 23, 2022
@andrii-bodnar andrii-bodnar added the help wanted Extra attention is needed label Feb 24, 2022
@dannyhuggins
Copy link
Author

is there a timeline for a bug fix for this? thanks in advance!

@serhii-londar
Copy link
Collaborator

@dannyhuggins Thank you for your report! Is it possible to reproduce on a simulator device or only on a real one?

@dannyhuggins
Copy link
Author

@serhii-londar unfortunately it's only possible to reproduce on a real device. The documents directory isn't accessible on real devices, so I'm not sure why Apple lets you access it on a tvOS simulator.

@dannyhuggins
Copy link
Author

I experimented the documentsPath by pointing it to the .cacheDirectory instead of the .documentDirectory. Since the cache directory can be purged by the device, I tested what happens if the cache is deleted. It appears that the SDK will reconstruct the cache, but the en.plist file that previously contained the translations is now empty and I can no longer user OTA translations. I was unable to repopulate the .plist via restarting the app. It seems the only way to refresh the OTA translations in the app to push a release with new translations.

I think it makes sense for iOS to continue using the documents directory to avoid file purges, but tvOS will likely need some additional caching functionality since that's the only directory available for file storage on AppleTV.

@Olena1234
Copy link

Hi there! Checking everything from our side

@serhii-londar
Copy link
Collaborator

@dannyhuggins Hi, can you please test whether changes from #180 request fixed that crash?

@dannyhuggins
Copy link
Author

hey @serhii-londar I will take a look, thanks!

@serhii-londar
Copy link
Collaborator

@dannyhuggins Did you have a chance to try the changes?

@dannyhuggins
Copy link
Author

@serhii-londar We are no longer seeing a crash with this fix! However, our team noticed that if the tvOS cache is cleared, we are not seeing Crowdin re-retrieve OTA translations and instead falls back to the bundled translations. Our guess is it has something to do with ETagStorage using UserDefaults but we aren’t sure.

@serhii-londar
Copy link
Collaborator

@dannyhuggins Thank you for checking it! Can you please send what path is used? Caches or Application Support?

@dannyhuggins
Copy link
Author

it's using the Application Support folder, at least on the simulator. Having an issue with my AppleTV at the moment

@serhii-londar
Copy link
Collaborator

Thank you, I will continue work on support.

@serhii-londar
Copy link
Collaborator

@dannyhuggins Hi. Can you try to use changes #177 branch? The issue with downloading localization after the cache is cleared should be fixed.

serhii-londar added a commit that referenced this issue May 11, 2022
serhii-londar added a commit that referenced this issue May 13, 2022
serhii-londar added a commit that referenced this issue Jun 6, 2022
Fix issue with crash on Apple TV devices.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants