Skip to content

[Bug report] Unable to Access MLKit Translator Model in iOS Share Extension #680

@Husseinhj

Description

@Husseinhj

Description:

I am encountering an issue with the MLKit translator module when using it in iOS share extensions or action extensions. The problem arises from the inability to access the MLKit translator model that is downloaded by MLKit, as it is stored in the applicationSupportDirectory. Unfortunately, when attempting to utilize the MLKit translator module within an extension service, the extension is unable to access the applicationSupportDirectory path, resulting in a failure to find the necessary model files.

[0]	(null)	"NSLocalizedDescription" : "Translation model files not found. Make sure to call downloadModelIfNeeded and if that fails, delete the models and retry."	

Steps to Reproduce:

  • Set up an iOS share extension or action extension project.
  • Integrate the MLKit translator module into the extension.
  • Call the downloadModelIfNeeded method to download the translator model.
  • Attempt to utilize the translator module within the extension's service code.

Expected Behavior:

The share extension or action extension should be able to access and utilize the downloaded MLKit translator model located in the applicationSupportDirectory.

Actual Behavior:

The extension is unable to locate and access the MLKit translator model in the applicationSupportDirectory, leading to an error indicating that the model files are not found.

Proposed Solution:

I believe that providing a mechanism for sharing the MLKit translator model files between the main app and app extensions would be a beneficial feature. One possible solution could be to incorporate support for app groups, allowing the MLKit translator module to store the model files in a shared container accessible by both the main app and the app extension. This would ensure that the translator model can be successfully utilized within extension services.

Additional Information:

I have verified that the issue is specific to app extensions, as the MLKit translator module functions correctly when used within the main app. It seems that the limitation lies in the inability of the share extension or action extension to access the applicationSupportDirectory path where the model files are stored.

Thank you for your attention to this matter. I appreciate your support in resolving this issue or considering the suggested feature enhancement.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions