Crash when RectCreate() is called

Product: Android Native SDK

Product Version: 9.4.2

Please give a brief summary of your issue:
Crash when com.pdftron.pdf.Rect.RectCreate is called

Please describe your issue and provide steps to reproduce it:
the app is crashing when com.pdftron.pdf.Rect.RectCreate (SourceFile) is called. I’m confused on how this is called right away. We are initializing the PDFTron SDK in our BaseActivity in it’s onCreate like so:

private fun initializePdfTron(context: Context) {
        val database = Firebase.database

        database.getReference("properties").child(PdftronDatabaseKey).get()
            .addOnSuccessListener { snapshot ->
                (snapshot.value as? String)?.let { value ->
                    try {
                        initializePDFNetApplication(context, value)
                    } catch (e: Exception) {
                        initializePDFNetApplication(context, PdftronKey)
                        logger.logError(
                            tag = this.javaClass.simpleName,
                            errorMessage = e.message + "Error initializing Pdftron key from Firebase Database, initialized with locally stored key",
                            e.cause
                        )
                    }
                }
            }
            .addOnFailureListener {
                initializePDFNetApplication(context, PdftronKey)
                logger.logError(
                    tag = this.javaClass.simpleName,
                    errorMessage = it.message + "Error initializing Pdftron key, initialized with stored key",
                    it.cause
                )
            }
    }

Here are the two errors coming in from our firebase logs:

Caused by java.lang.UnsatisfiedLinkError: No implementation found for long com.pdftron.pdf.Rect.RectCreate(double, double, double, double) (tried Java_com_pdftron_pdf_Rect_RectCreate and Java_com_pdftron_pdf_Rect_RectCreate__DDDD) - is the library loaded, e.g. System.loadLibrary?
       at com.pdftron.pdf.Rect.RectCreate(SourceFile)
       at com.pdftron.pdf.Rect.<init>(SourceFile:30)
       at com.pdftron.pdf.PDFViewCtrl$u.<init>(SourceFile:11012)
       at com.pdftron.pdf.PDFViewCtrl.<init>(SourceFile:15868)
       at com.pdftron.pdf.PDFViewCtrl.<init>(SourceFile:1943)
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
       at android.view.LayoutInflater.createView(LayoutInflater.java:876)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1028)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:983)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1145)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1106)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:544)
       at android.view.ViewStub.inflateViewNoAdd(ViewStub.java:272)
       at android.view.ViewStub.inflate(ViewStub.java:305)
       at com.pdftron.pdf.controls.PdfViewCtrlTabBaseFragment.loadStubPDFViewCtrl(PdfViewCtrlTabBaseFragment.java:3691)
       at com.pdftron.pdf.controls.PdfViewCtrlTabBaseFragment.loadPDFViewCtrlView(PdfViewCtrlTabBaseFragment.java:3702)
       at com.pdftron.pdf.controls.PdfViewCtrlTabFragment2.loadPDFViewCtrlView(PdfViewCtrlTabFragment2.java:255)
       at com.pdftron.pdf.controls.PdfViewCtrlTabBaseFragment.onViewCreated(PdfViewCtrlTabBaseFragment.java:1277)
       at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3128)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:552)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
       at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:113)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1433)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2977)
       at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:2888)
       at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3129)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:552)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
       at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:113)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1433)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2977)
       at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:2888)
       at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3129)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:552)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
       at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:113)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1433)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2977)
       at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:2888)
       at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3129)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:552)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
       at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:113)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1433)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2977)
       at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2895)
       at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:263)
       at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:351)
       at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1510)
       at android.app.Activity.performStart(Activity.java:8616)
       at android.app.ActivityThread.handleStartActivity(ActivityThread.java:4204)
       at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
       at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8762)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

and
Caused by android.view.InflateException: Binary XML file line #31 in com.canopytax.client:layout/fragment_tabbed_sub_pdfviewctrl_new: Error inflating class com.pdftron.pdf.PDFViewCtrl

Hi Seth,

This appears to be an issue on the order of operations, the PdfViewCtrl layout is being rendered before you have called initialized (due to waiting on the callback from Firebase). Please ensure initializePDFNetApplication is called before any view is shown.

As for why Rect.Create is called it appears to be coming from a lambda method:
at com.pdftron.pdf.PDFViewCtrl$u.<init>(SourceFile:11012)
Perhaps you have set a listener creating a Rect on init?

Thanks,
Andrew

This is confusing as to why PDFViewCtrl$u.<init> being called before the initialization of PDFTron because this crash is occurring on app launch within a second but no PDFViewCtrl is referenced unless the user navigates to a file which isn’t even an option on the main page of the app.

There is no where in our code where we set a listener to create a rectangle. Especially not on app launch

This is confusing as to why PDFViewCtrl$u.<init> being called before the initialization of PDFTron because this crash is occurring on app launch within a second but no PDFViewCtrl is referenced unless the user navigates to a file which isn’t even an option on the main page of the app.

From your stack trace it looks like PdfViewCtrlTabFragment2 being invoked by the Activity’s onStart(), therefore PdfViewCtrl is active during this crash:

       at com.pdftron.pdf.controls.PdfViewCtrlTabBaseFragment.loadPDFViewCtrlView(PdfViewCtrlTabBaseFragment.java:3702)
       at com.pdftron.pdf.controls.PdfViewCtrlTabFragment2.loadPDFViewCtrlView(PdfViewCtrlTabFragment2.java:255)

There is no where in our code where we set a listener to create a rectangle. Especially not on app launch

Rect is a helper class (not related to Annotations) that is used internally. This should be resolved if we fix the order of operation when initializePDFNetApplication gets called (this needs to be called before PdfViewCtrlTabFragment2. loadPDFViewCtrlView happens)


From what we can tell from your provided code the firebase success/failure listeners are async and your users could be launching the viewer before this is returned, so there is no guarantee that initialize will happen before the viewer gets rendered.

Thanks,
Andrew