speedyzhou / pdfium

Automatically exported from code.google.com/p/pdfium
0 stars 0 forks source link

PDFium doesn't initialize ICU when embedded in chrome #33

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
the pdfium sources contains a call to V8::InitializeICU() however, that is 
commented out for chrome builds.

Since ICU is linked statically into pdfium, the copy used by pdfium is not 
configured and trying to access it will result in a crash (see attached PoC)

Original issue reported on code.google.com by jochen@chromium.org on 4 Aug 2014 at 7:18

Attachments:

GoogleCodeExporter commented 9 years ago
Since PDFium in chrome runs in a sandbox it can't load the ICU data files from 
disk. Instead, we'll probably need to add an API to pass in either a file 
handle or a mmap'd copy of the data files.

Original comment by jochen@chromium.org on 4 Aug 2014 at 7:19

GoogleCodeExporter commented 9 years ago
I thought this used to work? 

Original comment by jam@chromium.org on 4 Aug 2014 at 4:46

GoogleCodeExporter commented 9 years ago
No, this has never worked, and I should have realized that much earlier....

Original comment by eisinger@google.com on 4 Aug 2014 at 4:56

GoogleCodeExporter commented 9 years ago
Yeah, so Android has a similar problem with ICU in Chromium. The result is the 
method InitializeICUWithFileDescriptor:

https://code.google.com/p/chromium/codesearch#chromium/src/base/i18n/icu_util.cc
&q=initializeicu&sq=package:chromium&type=cs&l=58

It would be worth looping in Jungshik Shin from the Chromium side, who knows 
the ICU initialization code VERY well.

Original comment by andrewha...@chromium.org on 14 Aug 2014 at 2:52

GoogleCodeExporter commented 9 years ago
I believe that now that we support loading V8's initial snapshot from external 
files in PDFium, this can be fixed using exactly the same approach as in

https://codereview.chromium.org/705623002/ for the in-renderer process
and
https://codereview.chromium.org/718453003/ for the plugin process

Instead of LoadV8Snapshot() and setting up the V8's startup data, one could add 
a new function called LoadICU() which would mmap icudtl.dat. Then 
InitializeICU() in base/i18n/icu_util.cc would be modified to only mmap the 
file (by calling LoadICU()) if it hasn't done so yet and then do the 
initialization.

In this way, when InitializeICU() is called in PDFium, this would just 
initialize ICU with the mmap'd file.

Original comment by ba...@chromium.org on 5 Dec 2014 at 11:49