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

Add SharedMemory service #1208

Merged
merged 5 commits into from
Jun 13, 2024
Merged

Add SharedMemory service #1208

merged 5 commits into from
Jun 13, 2024

Conversation

zatteo
Copy link
Contributor

@zatteo zatteo commented May 24, 2024

### 🔧 Tech

* Add SharedMemory service

Related to this PR : cozy/cozy-libs#2540

Checklist

Before merging this PR, the following things must have been done if relevant:

  • Tested on iOS
  • Tested on Android
  • Test coverage
  • README and documentation

Todo

Merge cozy/cozy-libs#2548 and update cozy-intent

@zatteo zatteo changed the title Add an In Memory store for webviews Add an data store in flagship app RAM for webviews May 24, 2024
@zatteo zatteo changed the title Add an data store in flagship app RAM for webviews Add SharedMemory service May 24, 2024
type Base64 = string

export const scanDocument = async (): Promise<Base64 | undefined> => {
try {
removeSharedMemory('mespapiers', 'scanDocument')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to clear this before doing the OS scan (that may produce memory flush too)? Would it be better to do this the later we can?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by memory flush ?

It has no meaning to do this cleaning later. But this cleaning is not necessary. It is just that if we are in this function this value has no meaning anymore because we overwrite it a few lines later.

Maybe I can remove it.

src/libs/localStore/sharedMemory.ts Outdated Show resolved Hide resolved
This SharedMemory service is an in memory store used to store data that can be retrieved later by Cozy webviews.
Sometimes, the operating system kill the mespapiers webview during a
'scanDocument' due to memory  constraints.

But the 'scanDocument' still run successfully. So we store
the result in SharedMemory service so that the mespapiers webview
will be able to retrieve it when it will be reloaded by the
SupervisedWebview.
To improve security, we want to be sure that a webview
only read the shared memory from this webview. So we
check the slug added by cozy-intent. We also need to
register this slug.
@zatteo zatteo merged commit 4fc3ced into master Jun 13, 2024
1 check passed
@zatteo zatteo deleted the feat/resilient-scan branch June 13, 2024 14:40
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.

3 participants