Androidpdfviewer: App crash when using ".pages()"

Created on 23 Dec 2017  ·  18Comments  ·  Source: barteksc/AndroidPdfViewer

Hey, I'm facing an issue since '3.0.0-beta.1'
I have a pdf with different size width. When I try to load a given page with .pages(1) for example, the pdf load a blurry page and the app crash when I try to scroll.

Here is my code :

pdf.fromAsset("file.pdf")
    .pages(1)
    .load();

Here is an example of file :
file.pdf

Here is the blurry image I get :
screenshot_1514037624
screenshot_1514037634

EDIT :
When I try to load all page (like .pages(1,0)) there is no problem

All 18 comments

What is logcat output?

There is no error in the logcat, the app just restart when I click on "Close app"

If it crashes logcat will show the error, post the error so people can help resolve the issue. Or at least you will see why it's throwing an error.

Ok, my mistake, the logcat show an error but not on the logcat application (because of the restart). Here is what I got :

12-27 22:08:19.848 2246-2723/com.android.systemui E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa245e0e0
12-27 22:08:19.869 2246-2723/com.android.systemui E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa245dd20
12-27 22:08:27.999 1942-1956/system_process E/ActivityManager: ANR in com.lereclus.yohann.testpdflibrary (com.lereclus.yohann.testpdflibrary/.MainActivity)
                                                               PID: 4749
                                                               Reason: Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago.  Wait queue length: 32.  Wait queue head age: 5708.3ms.)
                                                               Load: 0.27 / 0.95 / 0.58
                                                               CPU usage from 75219ms to 0ms ago:
                                                                 4.7% 1942/system_server: 3.3% user + 1.3% kernel / faults: 16916 minor
                                                                 1.6% 1233/surfaceflinger: 0.2% user + 1.4% kernel / faults: 27 minor
                                                                 0.4% 2784/com.google.android.gms: 0.3% user + 0.1% kernel / faults: 5825 minor
                                                                 0.3% 2246/com.android.systemui: 0.2% user + 0.1% kernel / faults: 7137 minor
                                                                 0.3% 1602/kworker/0:2: 0% user + 0.3% kernel
                                                                 0.3% 1243/adbd: 0% user + 0.2% kernel / faults: 5835 minor
                                                                 0.2% 2447/com.android.phone: 0% user + 0.1% kernel / faults: 1621 minor
                                                                 0.2% 3191/com.google.android.gms.unstable: 0.2% user + 0% kernel / faults: 2537 minor
                                                                 0.1% 3453/com.android.launcher3: 0% user + 0% kernel / faults: 1663 minor
                                                                 0.1% 1667/mediaserver: 0% user + 0% kernel / faults: 28 minor
                                                                 0.1% 2826/com.google.android.gms.persistent: 0% user + 0% kernel / faults: 2338 minor
                                                                 0% 8/rcu_preempt: 0% user + 0% kernel
                                                                 0% 1219/logd: 0% user + 0% kernel / faults: 26 minor
                                                                 0% 1664/debuggerd: 0% user + 0% kernel / faults: 2839 minor
                                                                 0% 13/kworker/1:0: 0% user + 0% kernel
                                                                 0% 2547/com.google.android.googlequicksearchbox:search: 0% user + 0% kernel / faults: 511 minor
                                                                 0% 1593/kworker/1:2: 0% user + 0% kernel
                                                                 0% 1207/kworker/0:1H: 0% user + 0% kernel
                                                                 0% 2221/android.process.acore: 0% user + 0% kernel / faults: 656 minor
                                                                 0% 1231/lmkd: 0% user + 0% kernel
                                                                 0% 1232/servicemanager: 0% user + 0% kernel
                                                                 0% 1659/jbd2/dm-0-8: 0% user + 0% kernel
                                                                 0% 3903/com.android.defcontainer: 0% user + 0% kernel / faults: 586 minor
                                                                 0% 4202/com.google.android.gms.ui: 0% user + 0% kernel
                                                                 0% 16/kworker/u4:1: 0% user + 0% kernel
                                                                 0% 2390/com.google.android.googlequicksearchbox:interactor: 0% user + 0% kernel / faults: 289 minor
                                                                 0% 2412/com.android.inputmethod.latin: 0% user + 0% kernel / faults: 187 minor
                                                                 0% 3008/com.google.android.apps.maps: 0% user + 0% kernel / faults: 12 minor
                                                                 0% 3403/com.android.deskclock: 0% user + 0% kernel / faults: 3 minor
                                                                 0% 3557/com.google.android.apps.photos: 0% user + 0% kernel / faults: 2 minor
                                                                 0% 3951/com.google.android.googlequicksearchbox: 0% user + 0% kernel / faults: 2 minor
                                                                 0% 4315/logcat: 0% user + 0% kernel / faults: 2 minor
                                                                +0% 4749/com.lereclus.yohann.testpdflibrary: 0% user + 0% kernel
                                                                +0% 4762/kworker/0:0: 0% user + 0% kernel
                                                               12% TOTAL: 10% user + 1.9% kernel + 0.1% iowait + 0% softirq
                                                               CPU usage from 953ms to 1456ms later:
                                                                 105% 4749/com.lereclus.yohann.testpdflibrary: 105% user + 0% kernel / faults: 1121 minor
                                                                   101% 4749/.testpdflibrary: 101% user + 0% kernel
                                                                   5.9% 4759/HeapTaskDaemon: 5.9% user + 0% kernel
                                                                   1.9% 4757/FinalizerDaemon: 0% user + 1.9% kernel
                                                                 1.9% 1942/system_server: 1.9% user + 0% kernel / faults: 2 minor
                                                                   1.9% 1956/ActivityManager: 1.9% user + 0% kernel
                                                               52% TOTAL: 52% user + 0% kernel
12-27 22:08:36.054 1233-1233/? E/EGL_emulation: tid 1233: eglCreateSyncKHR(1881): error 0x3004 (EGL_BAD_ATTRIBUTE)
12-27 22:08:36.077 1942-2030/system_process E/InputDispatcher: channel '7b2b490 com.lereclus.yohann.testpdflibrary/com.lereclus.yohann.testpdflibrary.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
12-27 22:08:36.127 1942-4103/system_process E/Surface: getSlotFromBufferLocked: unknown buffer: 0xae67dc60
12-27 22:08:36.146 1233-1233/? E/EGL_emulation: tid 1233: eglCreateSyncKHR(1881): error 0x3004 (EGL_BAD_ATTRIBUTE)
12-27 22:08:36.231 2246-2723/com.android.systemui E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa245e400
12-27 22:08:36.253 2246-2723/com.android.systemui E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa245dbe0

could you post the pdf on here ?

He is already on my first post :
file.pdf

Moreover, the error I got on my last post is coming from a blank app with only one activity and the pdfviewer, so I don't think this bug come only from me

sorry i missed the file i will load it up now

Loads fine for me.

add one of the following,

.pageFitPolicy(FitPolicy.HEIGHT) or .pageFitPolicy(FitPolicy.BOTH) or .pageFitPolicy(FitPolicy.WIDTH)

pdfview doesnt do multi size pages well.

Already tried the FitPolicy but it didn't work anyway. Have you tried to load only a given page with .pages(1) for example ? Because the problem show up only when I do that.

Here is the actual code I use :

public class MainActivity extends AppCompatActivity {

    PDFView pdfView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        pdfView = findViewById(R.id.pdfview);

        pdfView.fromAsset("file.pdf")
                .pages(1)
                .pageFitPolicy(FitPolicy.WIDTH)
                .load();
    }
}

I have no page marker, so i assume there is only one page but i do have a page border indicating two pages but they both fit one on page, but will try now.

mine displays page 1 at the top and the larger one at the bottom no issues with scroll or zoom.

pages(1,0)

Even when you select page 1 or 0 ? Because it should be displaying only one page if you put pages(0) or pages(1)
Btw, thanks for trying to help !

im always around here somewhere as always developing, page(1) gives me the chart in a bigger page works perfect.

device-2017-12-27-232458

Yes but it looks blurry (and it's not when viewing the whole pdf) and on a smaller screen when needed to scroll to see more of the pdf, the app crash

It doesnt like that very much, constant scrolling background sticky and crashed....

Background sticky concurrent mark sweep GC freed 1019935(23MB) AllocSpace objects, 0(0B) LOS objects, 8% free, 92MB/101MB, paused 1.025ms total 154.605ms

Yes. But the problem wasn't here on 2.8.0 so I think that's a real issue of version 3.0.0 @barteksc

Thanks, I will take a look

Fixed in 3.0.0-beta.5 version

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dongliang0201 picture dongliang0201  ·  8Comments

titosobabas picture titosobabas  ·  4Comments

proguru58 picture proguru58  ·  7Comments

vincecarterhu picture vincecarterhu  ·  6Comments

QiaoYang0923 picture QiaoYang0923  ·  4Comments