Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC:

ANR problems using RadaeePDF 3.55.5 RC1 in Android 11+ 2 years 11 months ago #15490

  • Osorio
  • Osorio's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 4
  • Thank you received: 0
Hello RadaeePDF team, recently we updated the SDK version to RadaeePDF 3.55.5 RC1 but we found some troubles when the application is downloading the PDF to local storage and we tried to paginate over the PDFs, the screen freezes and an ANR message appears on the screen, this happens only with devices having Android 11+. The LogCat shows the following information without any exceptions of our code:

D/ViewRootImpl: not support adaptive color gamut feature!
V/ViewRootImpl: The specified message queue synchronization  barrier token has not been posted or has already been removed
D/ViewRootImpl[MainActivity]: windowFocusChanged hasFocus=false inTouchMode=true
E/sqlite3_android: [IKR-38846] ONEPLUS_NAME_PARTS_MATCH SQLITE_OK
E/sqlite3_android: [IKR-38846] ONEPLUS_NAME_PARTS_MATCH SQLITE_OK
E/reforma.elnort: Invalid ID 0x00000000.
W/Choreographer: Already have a pending vsync event.  There should only be one at a time.
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@48c21b9[ImpresaActivity]
D/ViewRootImpl[ImpresaActivity]: windowFocusChanged hasFocus=true inTouchMode=true
I/reforma: Thread[2,tid=29558,WaitingInMainSignalCatcherLoop,Thread*=0xb400007da5ce4b20,peer=0x14040238,"Signal Catcher"]: reacting to signal 3
I/reforma: Wrote stack traces to tombstoned

We search for information related to the "tombstones" message and is referring to when a native crash in C/C++ is raised in an Android application.

Previously we were using SDK version 3.15.1 of PDF and this problem didn't happen. 

Could you please help us to solve this problem?

Please Log in or Create an account to join the conversation.

ANR problems using RadaeePDF 3.55.5 RC1 in Android 11+ 2 years 11 months ago #15491

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
dear user:
the log seems not help to us.
we suspect the downloading codes cause ANR, what's code are you using to download the PDF file?
 

Please Log in or Create an account to join the conversation.

ANR problems using RadaeePDF 3.55.5 RC1 in Android 11+ 2 years 10 months ago #15496

  • jomart
  • jomart's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 1
Hello Support,

This is our code:

    • Downloading pdf to local storage:


    @Override
    public void run(){
        saveOnDisk(pdfB, listener);
    }
    
    private void saveOnDisk(final byte[] bytesPDF, final DownloadPdfFileListener pdfListener ){
        new Thread(){
            @Override
            public void run(){
                writeFileToDisk(bytesPDF, pdfPath, Utilities.md5(url));
                sendMessage(bytesPDF, (pdfPath + Utilities.md5(url)), pdfListener);
            }
        }.start();
    }
    
    public static boolean writeFileToDisk(byte[] rawData, String path, String fileName){
        boolean result = false;
        FileOutputStream fos;
        try{
            if(rawData != null && rawData.length > 0){
                File dir = new File(path);
                if(!dir.exists()){
                    dir.mkdirs();
                }
                fos = new FileOutputStream(new File(path + fileName));
                fos.write(rawData);
                fos.flush();
                fos.close();
                result = true;
            }
        } catch (FileNotFoundException e) {
            Log.w(TAG, "writeFileToDisk() FileNotFoundException: " + e.getMessage());
        } catch (IOException e) {
            Log.w(TAG, "writeFileToDisk() IOException: " + e.getMessage());
        }
        return result;
    }
    
    private void sendMessage(final byte[] bytes ,final String pathLocalPDF, final DownloadPdfFileListener pdfListener ){
        new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public void run() {
                if(pdfListener != null){
                    pdfListener.onPdfReady(bytes, pathLocalPDF);
                }    
            }
        },1000);
    }

    • Renderization:

    private void renderPDF(byte[] pdfStream, CustomPDFReader pdfReader) {
        View v = getView();
        if (v != null) {
            if (pdfStream != null && pdfStream.length > 0) {
                Document pdf = new Document();
                int result = pdf.OpenMem(pdfStream, v.getContext().getString(R.string.pdf_key));
                logResult(result);
                pdfReader.PDFOpen(pdf, pdfReader);
                pdfReader.setVisibility(View.VISIBLE);
                pdfReader.setOverScroll(overScroll);
            } else {
                Utilities.showCustomToast("No se logró descargar la página.", Toast.LENGTH_SHORT, Utils.TOAST_CENTER, v.getContext());
            }
            showProgress(v, false);
        }
    }

We install this app in some devices and we realized using the message text "AvialMem:" (Available memory) that the memory consumption in devices having Android 11+ is greater than devices having Android 10--.

Tests when pdf is rendered:

• One Plus Nord Android 11: AvialMem 1710 M
• Pixel 3 Android 12 Beta: AvialMem 1017 M
• Huawei Y9 Android 9: AvialMem 779 M


Most of the time when we open the pdf in Android 11+ the screen freezes and an ANR message appears on the screen (you can see in the GIF when we open the pdf in Android 11) while in Android 9 the PDF is rendered without any problem and we can paginate.

Gif One Plus Nord Android 11:
drive.google.com/file/d/1U9kuPyBsHFKZXe_...HQq/view?usp=sharing
Attachments:
The following user(s) said Thank You: Osorio

Please Log in or Create an account to join the conversation.

Last edit: by jomart.

ANR problems using RadaeePDF 3.55.5 RC1 in Android 11+ 2 years 10 months ago #15497

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
dear user:
the download code seems not attached here.
i suspect the http connection and reading blocks the UI.
generally speaking,
http downloading and other heavy task(like Database/huge file writing) shall run on backing thread, and a progress dialog shall display on UI while opening.

and i noticed that, our demo project open PDF file in backing thread, this can avoid block the UI thread, when PDF file is very huge, like 100000 pages.
please read demo class: com.radaee.reader.PDFNavAct.OpenTask in PDFNavAct.java

Please Log in or Create an account to join the conversation.

Last edit: by radaee.

ANR problems using RadaeePDF 3.55.5 RC1 in Android 11+ 2 years 10 months ago #15506

  • jomart
  • jomart's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 1
Hello support,

We used an AsyncTask and this problem was solve.

Thank you.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum