pdfium-lib icon indicating copy to clipboard operation
pdfium-lib copied to clipboard

Update emscripten to version 3

Open paulocoutinhox opened this issue 2 years ago • 3 comments

Hi,

I need some help to update this project to use Emscripten version 3+.

I already make the port in the branch: https://github.com/paulocoutinhox/pdfium-lib/tree/emscripten.

But when i try load any PDF, it throws this error:

image

Related code:

console.log('INIT 1');
FPDF.Init();   // <- here is the problem
console.log('INIT 2');

Can anyone help me debug/understand?

Thanks.

paulocoutinhox avatar May 24 '22 16:05 paulocoutinhox

Hi guys,

@cetinsert @Priestch @quincarter can you try help me finish it when you have time?

Thanks.

paulocoutinhox avatar May 24 '22 16:05 paulocoutinhox

I'll see if i can do something with this. I'll play with this over the weekend.

quincarter avatar Jun 01 '22 23:06 quincarter

@paulocoutinhox I'm also looking into this. The main problem seems to be the memory allocator. PDFium uses ASLR but Emscripten 3 does not support giving a hint address when calling mmap, which is needed to do ASLR. See https://github.com/emscripten-core/emscripten/blob/1bbb5f8dea4422768bdc9a9a44ce8a9eb6dd39c9/system/lib/libc/emscripten_mmap.c#L119

I'm working on creating a standalone WASM build so that we can use it in a Go runtime, and so far it's not going too well :crying_cat_face: New problems every step of the way.

We could look into disabling ASLR in PDFium so that it can call mmap and allocate the memory pages it needs.

jerbob92 avatar Sep 24 '22 11:09 jerbob92

Hi,

I will refactor all and remake a lot of things in this project. And when i start it, i will change this too.

Im only finishing another open source project that is a requirement for me.

Stay tuned here and feel free to donate to help project development.

Thanks.

paulocoutinhox avatar Oct 21 '22 01:10 paulocoutinhox

Hi @paulocoutinhox,

I'm just curious, but what are your plans regarding this ticket and the remake? Because I really want to get this WASM pdfium build to work correctly, but the way I'm seeing it now, it totally depends on someone making a patch for pdfium to fix up the memory allocation, and it doesn't really have to do with this or any other pdfium build project.

jerbob92 avatar Oct 27 '22 18:10 jerbob92

@paulocoutinhox check this out: https://github.com/bblanchon/pdfium-binaries/issues/28#issuecomment-1293957584

jerbob92 avatar Oct 27 '22 19:10 jerbob92

Hi,

All problems was fixed in new release.

You can check here: https://github.com/paulocoutinhox/pdfium-lib/releases/tag/5407

The demo is here: https://pdfviewer.github.io/

Feel free to donate to help project development.

Thanks.

paulocoutinhox avatar Nov 08 '22 18:11 paulocoutinhox