ARK-Builders / ark-android

Reusable components for the ARK project
https://www.ark-builders.dev
MIT License
0 stars 1 forks source link

Crash in `pdfPreviewGenerateNative` API #64

Open tuancoltech opened 11 months ago

tuancoltech commented 11 months ago

This happens when clicking on Navigate data in Navigator app with some PDF files. Related: https://github.com/ARK-Builders/ARK-Navigator/issues/412

Cmdline: dev.arkbuilders.navigator
pid: 11803, tid: 12465, name: DefaultDispatch  >>> dev.arkbuilders.navigator <<<
uid: 10716
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
    x0  0000000000000000  x1  00000000000030b1  x2  0000000000000006  x3  00000079040392d0
    x4  00000000ebad808a  x5  00000000ebad808a  x6  00000000ebad808a  x7  3f8000003f800000
    x8  00000000000000f0  x9  8246067d94e6f48d  x10 0000000000000000  x11 ffffff80fffffbdf
    x12 0000000000000001  x13 0000000000000070  x14 0000000071931070  x15 0000007904039138
    x16 0000007bbeb8d050  x17 0000007bbeb69eb0  x18 fffffffffffffff8  x19 0000000000002e1b
    x20 00000000000030b1  x21 00000000ffffffff  x22 000000789d838850  x23 0000007904039580
    x24 000000789ceab8a0  x25 000000789d8f9a60  x26 000000790403b21c  x27 000000790403b210
    x28 000000790403b110  x29 0000007904039350
    lr  0000007bbeb1cba0  sp  00000079040392b0  pc  0000007bbeb1cbcc  pst 0000000000000000

backtrace:
      #00 pc 000000000004fbcc  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: ba489d4985c0cf173209da67405662f9)
      ARK-Builders/arklib#1 pc 0000000000bf3674  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (std::sys::unix::abort_internal::h4cbe40d43106b45b+4)
      ARK-Builders/arklib#2 pc 0000000000bf0e40  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (rust_panic+76)
      ARK-Builders/arklib#3 pc 0000000000bf0c64  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (std::panicking::rust_panic_with_hook::h9c80bfe4d552cb32+660)
      ARK-Builders/arklib#4 pc 0000000000bf09b0  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (std::panicking::begin_panic_handler::_$u7b$$u7b$closure$u7d$$u7d$::haece24ab2b06546c+196)
      ARK-Builders/arklib#5 pc 0000000000bef6a4  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (std::sys_common::backtrace::__rust_end_short_backtrace::h5255d8dea90e7932+4)
      ARK-Builders/arklib#6 pc 0000000000bf0700  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (rust_begin_unwind+108)
      ARK-Builders/arklib#7 pc 0000000000c0faac  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (core::panicking::panic_fmt::h61a82d7f25335953+44)
      ARK-Builders/arklib#8 pc 0000000000c0fe5c  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (core::result::unwrap_failed::h0973c0cfe8c3b00d+88)
      ARK-Builders/arklib#9 pc 00000000004461dc  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (core::result::Result$LT$T$C$E$GT$::unwrap::hd97d7155f1a185bd+152)
      ARK-Builders/arklib#10 pc 0000000000448f60  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (arklib::pdf::render_preview_page::he4a0f3d9b25ab6ef+1860)
      ARK-Builders/arklib#11 pc 0000000000435dd4  /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!libarklib.so (Java_dev_arkbuilders_arklib_LibKt_pdfPreviewGenerateNative+1768)
      ARK-Builders/arklib#12 pc 0000000000461554  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: 12e00d030bcfeb51f978c01791e0cd24)
      #13 pc 0000000000209398  /apex/com.android.art/lib64/libart.so (nterp_helper+152) (BuildId: 12e00d030bcfeb51f978c01791e0cd24)
      ARK-Builders/arklib#14 pc 00000000002468bc  [anon:dalvik-classes16.dex extracted in memory from /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!classes16.dex]
      ARK-Builders/arklib#15 pc 0000000000209334  /apex/com.android.art/lib64/libart.so (nterp_helper+52) (BuildId: 12e00d030bcfeb51f978c01791e0cd24)
      ARK-Builders/arklib#16 pc 000000000025120e  [anon:dalvik-classes16.dex extracted in memory from /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!classes16.dex]
      ARK-Builders/arklib#17 pc 000000000020a254  /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: 12e00d030bcfeb51f978c01791e0cd24)
      ARK-Builders/arklib#18 pc 0000000000251092  [anon:dalvik-classes16.dex extracted in memory from /data/app/~~UopwbnBLZsui9cjV_wT07g==/dev.arkbuilders.navigator-HVeIdiZtVWBKhm-dfxJI2A==/base.apk!classes16.dex]
      ARK-Builders/arklib#19 pc 00000000020bd4b8  /memfd:jit-cache (deleted)
tuancoltech commented 11 months ago

I had been debugging this issue in this branch (placed some logs there), just in case somebody needs a reference to where I was: https://github.com/ARK-Builders/arklib/pull/59/files

gwendalF commented 11 months ago

@tuancoltech Do you know in what circumstance it crash? I was able to save image with High Quality directly without error

tuancoltech commented 11 months ago

@tuancoltech Do you know in what circumstance it crash? I was able to save image with High Quality directly without error

@gwendalF Have you setup the environment as described in this issue? https://github.com/ARK-Builders/ARK-Navigator/issues/412 Then, after the setup, go to Navigatge data tab in Navigator app, it will crash.

gwendalF commented 11 months ago

@tuancoltech I don't have the Java environement ready. The stacktrace you describe say it crash on unwrap. There is 4 unwrap here:

    PDFIUM
        .get()
        .unwrap()
        .load_pdf_from_reader(data, None)
        .unwrap()
        .pages()
        .get(0)
        .unwrap()
        .render_with_config(&render_cfg)
        .unwrap()
        .as_image()

Can you describe the parameters you pass to the function?

tuancoltech commented 10 months ago

@tuancoltech I don't have the Java environement ready. The stacktrace you describe say it crash on unwrap. There is 4 unwrap here:

    PDFIUM
        .get()
        .unwrap()
        .load_pdf_from_reader(data, None)
        .unwrap()
        .pages()
        .get(0)
        .unwrap()
        .render_with_config(&render_cfg)
        .unwrap()
        .as_image()

Can you describe the parameters you pass to the function?

@gwendalF Sorry I just missed this comment. The only param that I think you'll need is the previewQuality, which is MEDIUM in case of crash. However, as per my earlier investigation, it seems to happen with other qualities too. Let me know if you need further info (I can reproduce the crash 100% of the times).

kirillt commented 9 months ago

Complete this first: