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

tvOS not logging on real device #172

Merged
merged 2 commits into from
Mar 10, 2023
Merged

tvOS not logging on real device #172

merged 2 commits into from
Mar 10, 2023

Conversation

mmmcheese
Copy link
Contributor

The fallback was never being registered. Once registered it seems to be configured and allow the user to enable remote logging etc. There may be assumptions elsewhere as the logs still don’t seem to persist. This likely requires more investigation.

Use the caches directory for appleTV hardware as this is the only available directory on tvOS. It is more temporary, and often is cleared on backgrounding, but at least it’s available.

The fallback was never being registered. Once registered it seems to be configured and allow the user to enable remote logging etc. There may be assumptions elsewhere as the logs still don’t seem to persist. This likely requires more investigation.
Use the caches directory for appleTV hardware as this is the only available directory on tvOS. It is more temporary, and often is cleared on backgrounding, but at least it’s available.
@kean
Copy link
Owner

kean commented Mar 9, 2023

Thanks for taking this on, @mmmcheese.

The in-memory store is not really designed be used. It's there just to make the complier happy and avoid force unwraps. Maybe now is a good time to make it work properly because, here is what I found out about tvOS from quick research:

The first thing to understand here is that tvOS was designed as an always connected system, and thus apps generally don’t store user data on the Apple TV.

Source: https://developer.apple.com/forums/thread/89008

Moreover, your app can only access 500 KB of persistent storage that is local to the device (using the NSUserDefaults class). Outside of this limited local storage, all other data must be purgeable by the operating system when space is low.

Source: https://developer.apple.com/library/archive/documentation/General/Conceptual/AppleTV_PG/index.html#//apple_ref/doc/uid/TP40015241

I don't think the linked guide states anything specific about the library folder. But here what it does say: "Your app can download the data it needs into its cache directory.". So I suggest trying the caches directory. I think it should work well enough. It's OK if occasionally the logs get purged. Pulse does it itself occasionally already anyway.

@mmmcheese
Copy link
Contributor Author

Thanks for taking this on, @mmmcheese.

The in-memory store is not really designed be used. It's there just to make the complier happy and avoid force unwraps. Maybe now is a good time to make it work properly because, here is what I found out about tvOS from quick research:

The first thing to understand here is that tvOS was designed as an always connected system, and thus apps generally don’t store user data on the Apple TV.
Source: https://developer.apple.com/forums/thread/89008

Moreover, your app can only access 500 KB of persistent storage that is local to the device (using the NSUserDefaults class). Outside of this limited local storage, all other data must be purgeable by the operating system when space is low.
Source: https://developer.apple.com/library/archive/documentation/General/Conceptual/AppleTV_PG/index.html#//apple_ref/doc/uid/TP40015241

I don't think the linked guide states anything specific about the library folder. But here what it does say: "Your app can download the data it needs into its cache directory.". So I suggest trying the caches directory. I think it should work well enough. It's OK if occasionally the logs get purged. Pulse does it itself occasionally already anyway.

The main fix is using the cache directory on tvOS. I happened to leave in the changes to the fallback, but since they don't work they could also be ignored for now.

@kean
Copy link
Owner

kean commented Mar 10, 2023

Thanks, merging it. I'll switch the default back to the library directory if you don't mind. I think it's the right one for these sort of files (reference: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html).

I appreciate you taking the time to fix it!

@kean kean merged commit 42005d0 into kean:main Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants