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

Reduce the memory usage of PDF asset file content parsing on the mobile #9079

Closed
88250 opened this issue Aug 31, 2023 · 7 comments
Closed

Reduce the memory usage of PDF asset file content parsing on the mobile #9079

88250 opened this issue Aug 31, 2023 · 7 comments
Assignees

Comments

@88250
Copy link
Member

88250 commented Aug 31, 2023

Otherwise, it is easy to cause the application to crash when indexing asset files on the mobile.

@88250
Copy link
Member Author

88250 commented Aug 31, 2023

@nekrondev Hello, I tested a PDF here. The memory occupied by a single core is about 1G. If it is 4 cores, it will take more than 3G, so it will cause the mobile app to crash.

Do you currently have a better way to reduce memory usage? If you need the PDF sample, please send me an email (845765@qq.com), and I will send you this PDF sample as an email attachment, thank you.

@88250 88250 changed the title Reduce the memory usage of PDF asset file content parsing Reduce the memory usage of PDF asset file content parsing on the mobile Aug 31, 2023
@88250 88250 self-assigned this Aug 31, 2023
@88250 88250 added this to the 2.10.3 milestone Aug 31, 2023
@zxhd863943427
Copy link
Contributor

2.10.2的移动端似乎并不能搜索资源文件。

@88250
Copy link
Member Author

88250 commented Aug 31, 2023 via email

@nekrondev
Copy link
Contributor

Hello @88250 I'll have a closer look into this. The go-pdfium project writes about memory consumption if multiple workers are added. I think I'll do some investigation into dynamically allocating a worker pool if there is no memory pressure, i.e. read the available system memory and launch more or less workers.

@88250
Copy link
Member Author

88250 commented Aug 31, 2023

I'm not sure if there is a way to get the currently available memory on the mobile. Now the dev branch has limited the mobile to 1 core.

@nekrondev
Copy link
Contributor

That looks like a good solution to me! I'll continue my tests with dynamic worker pool and see if I can provide some solution eventually. The problem could be that once allocated memory by the WASM runtime will only GC'ed when the go-pdfium pool will close releasing the runtime and allowing GC to cleanup heap and stack.

EightDoor added a commit to EightDoor/siyuan that referenced this issue Sep 1, 2023
* commit 'a63e1fda2e203917ae7f72cb359155f4094c4f3e': (217 commits)
  ⚡ Improve block loading performance on Windows/Linux/macOS amd64 arch siyuan-note#9084
  💄
  ⚡ Improve block loading performance on Windows/Linux/macOS amd64 arch siyuan-note#9084
  🐛 Block hyperlinks do not point to regenerated block IDs when importing .sy.zip siyuan-note#9083
  🎨 Reduce the memory usage of PDF asset file content parsing on the mobile siyuan-note#9079
  🎨 HTTPS certificate is no longer verified when `Convert network images to local images` siyuan-note#9080
  🐛 fix siyuan-note#9076
  🐛 fix siyuan-note#9076
  🐛
  🎨 siyuan-note#9068
  🎨 Improve the response status code of  kernel API `/api/file/getFile` siyuan-note#9075
  Improve the response status code of  kernel API `/api/file/getFile` (siyuan-note#9075)
  ✨ siyuan-note#9032siyuan-note#9032
  🐛 The update button is not displayed after the marketplace package version is updated Fix siyuan-note#9074siyuan-note#9032
  🎨 Improve asset file content search preview escaping siyuan-note#9073
  🎨 Improve asset file content search preview escaping siyuan-note#9073
  🎨 Improve EPUB asset file content parsing siyuan-note#9072
  ♻️ siyuan-note#9032
  ...

# Conflicts:
#	README.md
@88250
Copy link
Member Author

88250 commented Sep 3, 2023

@nekrondev

It was only found through today's test that the mobile does not support PDF parsing and an error will be reported under Android:

convert [/storage/emulated/0/Android/data/org.b3log.siyuan/files/siyuan/temp/convert/asset_content/u6uhcrz.pdf] failed: [could not instantiate webassembly module: module[] function[_initialize] failed : permission denied (recovered by wazero)

It will directly cause a crash under iOS (I guess wazero is not compatible with iOS).

For PDF parsing, let's give up mobile support for now, I describe this limitation in the user guide.

@88250 88250 removed the Enhancement label Sep 3, 2023
@88250 88250 removed this from the 2.10.3 milestone Sep 3, 2023
88250 added a commit that referenced this issue Sep 3, 2023
@88250 88250 closed this as completed Sep 3, 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

No branches or pull requests

3 participants