alpaca-core / ac-local

Alpaca Core local inference SDK
MIT License
1 stars 0 forks source link

Investigate using IOS download manager as an asset source #64

Closed iboB closed 1 month ago

iboB commented 2 months ago

Report results in #52

iboB commented 2 months ago

Maybe use self hosting + ngrok server so you can have easy access to files

https://github.com/TheWaWaR/simple-http-server is also useful for self hosting (as opposed to huge beasts like nginx)

pminev commented 1 month ago

After some time under investigation I can explain what approaches we have on iOS:

  1. App Groups

    • In the app's project you can define a specific group (string) to associate the app which will give you access to the shared folder for this group, so multiple apps can share common files
    • This works only if the developer team which is signing the app is the same - won't work for us
  2. External storage providers (iCloud, Firebase, etc)

    • since we're searching a way to store models locally this is not solution for us
  3. Share files via URL schemes

    • This works only if specific app add a key-value pair in it's "Info.plist" descriptor file with which other apps can share files.
    • After that they can share links between each other like; appA://someURLFromAppA, appB://someURLFromAppB
    • This is not suitable for us since it's unacceptable to make users do such thing
  4. Store them in global folder

    • This seems like the only reasonable solution for now but there are some challenges to address
    • Due to the sandboxing architecture of the iOS apps we can't directly download to global folder (managed to download it in local folder for the specific app) since we don't have access. (I haven't found a way to grant a permission to write to global folder yet)
    • We can download to a local folder of the app then somehow export it to a global level. - Research is in progress

TLDR: We should download assets to a common place like a Downloads/Documents folder which will be visible from the Files app (I guess). However, due to the iOS app's sandboxing architecture seems to be a blocker for now. I'll continue to research for a solution how to bypass the limitations we have now.

pminev commented 1 month ago

On iOS, it is not possible to create or share a global folder that multiple apps can access directly, especially between apps from different developers without user input. This is due to iOS’s strict sandboxing model, which ensures that each app is isolated from others for security and privacy reasons. Each app has its own file system and cannot access another app's files directly.

The only solution which might work for now is to to use UIDocumentPicker for accessing files (export/import) but that would require user-input which makes it very inconvenient.

iboB commented 1 month ago

Are there no permissions or one time user actions that can grant access to an entire directory?

Can we read list of directory files even if we can't access individual files?

iboB commented 1 month ago

Also can we ask permission for a file if it doesn't exist? :)

pminev commented 1 month ago

I have managed to give access to a folder which is global by the UIDocumentPicker but it looks like it works only during lifetime of the app. Once it's closed I have to ask for a permission again from the user.

pminev commented 1 month ago

I've managed to have some working solution. It's not the best but I think it's the only one, so the process is as follows:

pminev commented 1 month ago

I'll write a document with the summarized informations. What approaches we've tried and what will work.

IvanFilipov commented 1 month ago

I'll write a document with the summarized informations. What approaches we've tried and what will work.

If this document is ready, where is it stored? - is it the .md from https://github.com/alpaca-core/alpaca-core/commit/84bb2a9e7e96d850625ef1d51acaed97d1c40787? I would like to understand you approach on iOS before starting with Android (on the same topic - download asset management). The two solutions (as implementation) are likely to be quite different, but still, the idea shall be quite similar.

pminev commented 1 month ago

@IvanFilipov That's the document, yes.

IMO, the solutions will be very platform dependent since there are a lot of restrictions on iOS platform.

pminev commented 1 month ago

@iboB Gave the idea to check if we create a framework from our library - not a static one. And it's already signed by us, will that help us to create an app.group. We'll need to check that or the app groups work only on app bundles level.

iboB commented 1 month ago

closing this as part of #139