phrase / phrase-android

Phrase Over the Air Android SDK
https://phrase.com
Other
6 stars 1 forks source link

Phrase SDK crash webview on forms opening AlertDialog #60

Open debase opened 12 months ago

debase commented 12 months ago

Context

We are using phrase SDK 3.5.0 in our project opening in app webviews containing \<fieldset> html property which basically tries to open an alert dialog.

Observed behavior

When opening a in app webviews url containing \<fieldset> property when clicking on it to select, the app crash with stack trace:

Process: com.example.phraseotacrashwebviews, PID: 32444
              android.content.res.Resources$NotFoundException: Resource ID #0x0
               at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:226)
               at android.content.res.Resources.loadXmlResourceParser(Resources.java:2504)
               at android.content.res.Resources.getLayout(Resources.java:1261)
               at androidx.appcompat.widget.ResourcesWrapper.getLayout(ResourcesWrapper.java:204)
               at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
               at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:425)
               at android.widget.ArrayAdapter.getView(ArrayAdapter.java:416)
               at WV.rj0.getView(chromium-TrichromeWebViewGoogle6432.aab-stable-584516333:11)
               at android.widget.AbsListView.obtainView(AbsListView.java:2421)
               at android.widget.ListView.measureHeightOfChildren(ListView.java:1417)
               at android.widget.ListView.onMeasure(ListView.java:1323)
               at android.view.View.measure(View.java:26362)
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6981)
               at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
               at android.view.View.measure(View.java:26362)
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6981)
               at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
               at android.view.View.measure(View.java:26362)
               at com.android.internal.widget.AlertDialogLayout.tryOnMeasure(AlertDialogLayout.java:146)
               at com.android.internal.widget.AlertDialogLayout.onMeasure(AlertDialogLayout.java:71)
               at android.view.View.measure(View.java:26362)
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6981)
               at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
               at android.view.View.measure(View.java:26362)
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6981)
               at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
               at android.view.View.measure(View.java:26362)
               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6981)
               at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
               at com.android.internal.policy.DecorView.onMeasure(DecorView.java:758)
               at android.view.View.measure(View.java:26362)
               at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3916)
               at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2609)
               at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2902)
               at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2354)
               at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9078)
               at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1346)
               at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1354)
               at android.view.Choreographer.doCallbacks(Choreographer.java:1005)
               at android.view.Choreographer.doFrame(Choreographer.java:936)
               at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322)
               at android.os.Handler.handleCallback(Handler.java:942)
               at android.os.Handler.dispatchMessage(Handler.java:99)
               at android.os.Looper.loopOnce(Looper.java:227)
               at android.os.Looper.loop(Looper.java:327)
               at android.app.ActivityThread.main(ActivityThread.java:7995)
               at java.lang.reflect.Method.invoke(Native Method)
               at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)

Expected behavior

App should not crash on selection and should open the alert dialog

Step to reproduce

Sample project here which just open url "https://eu.claims.axa.travel/claim_form/form" in a webview Just clicking on "country of residence" form field make the app crash. Commenting override fun getDelegate(): AppCompatDelegatesolve the issue.

theSoenke commented 12 months ago

@debase thank you for even preparing a sample project. That's really helpful and I've prepared a task to resolve this. I'll keep you posted here

theSoenke commented 10 months ago

Hi @debase, this should be resolved in version https://github.com/phrase/phrase-android/releases/tag/3.7.1. Could you try it with the latest release?

Valentin-Buculei commented 9 months ago

For me the issue still happens in 3.7.3

android.content.res.Resources$NotFoundException: Resource ID #0x0 at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:265) at android.content.res.MiuiResourcesImpl.getValue(MiuiResourcesImpl.java:96) at android.content.res.Resources.loadXmlResourceParser(Resources.java:2607) at android.content.res.Resources.getLayout(Resources.java:1314) at androidx.appcompat.widget.ResourcesWrapper.getLayout(ResourcesWrapper.java:204) at android.view.LayoutInflater.inflate(LayoutInflater.java:537) at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:425) at android.widget.ArrayAdapter.getView(ArrayAdapter.java:416) at WV.DM.getView(chromium-TrichromeWebViewGoogle6432.aab-stable-604506633:11) at android.widget.AbsListView.obtainView(AbsListView.java:2424) at android.widget.ListView.measureHeightOfChildren(ListView.java:1417) at android.widget.ListView.onMeasure(ListView.java:1323) at android.view.View.measure(View.java:26640) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7060) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:26640) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7060) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:26640) at com.android.internal.widget.AlertDialogLayout.tryOnMeasure(AlertDialogLayout.java:146) at com.android.internal.widget.AlertDialogLayout.onMeasure(AlertDialogLayout.java:71) at android.view.View.measure(View.java:26640) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7060) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:26640) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7060) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:26640) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7060) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:835) at android.view.View.measure(View.java:26640) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:4145) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2810) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3116) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2546) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9498) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1459) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1467) at android.view.Choreographer.doCallbacks(Choreographer.java:1089) at android.view.Choreographer.doFrame(Choreographer.java:1003) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1435) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:211) at android.os.Looper.loop(Looper.java:300) at android.app.ActivityThread.main(ActivityThread.java:8395) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:559) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)

valeriiia commented 8 months ago

Hi. I also experience this issue in 3.7.3.

theSoenke commented 8 months ago

Hi @Valentin-Buculei and @valeriiia, thanks for the report. Does this issue occur for you when opening the alert dialog as well or a different action inside a webview?

valeriiia commented 8 months ago

Hi. For me it occurs when one tries to pick a date and time on the webview. When the date/time dialog appears the app crashes. Once we've disabled the Phrase this crash disappear

Cheers, Valeriia

On Tue, Dec 19, 2023, 9:16 AM theSoenke @.***> wrote:

Hi @Valentin-Buculei https://github.com/Valentin-Buculei and @valeriiia https://github.com/valeriiia, thanks for the report. Does this issue occur for you when opening the alert dialog as well or a different action inside a webview?

— Reply to this email directly, view it on GitHub https://github.com/phrase/phrase-android/issues/60#issuecomment-1862306786, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUGZGGJ4SD4UKF3QSDS3ZW3YKFEPXAVCNFSM6AAAAAA4T2HJDOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRSGMYDMNZYGY . You are receiving this because you were mentioned.Message ID: @.***>

Valentin-Buculei commented 8 months ago

Hi @Valentin-Buculei and @valeriiia, thanks for the report. Does this issue occur for you when opening the alert dialog as well or a different action inside a webview?

yes, when it opens a dialog (after clicking on a <select> element)

valeriiia commented 6 months ago

Hello. Are there any updates on this issue or any workarounds? Thanks

theSoenke commented 6 months ago

Hey @valeriiia, unfortunately I don't have an update yet. There are 1-2 things we'll have to resolve before in the SDK and then this will be next priority to resolve.

Valentin-Buculei commented 6 months ago

Hello. Are there any updates on this issue or any workarounds? Thanks

A workaround would be to open the dialog from a new, translucent activity that does not call Phrase.getDelegate()

MehdiBrahmi commented 4 months ago

Hello @theSoenke and @Valentin-Buculei

We encountered the same issue on our application with your latest SDK v3.9.0.

Is a fix coming soon?

Thanks.

bartlomiej-sory-home24 commented 3 months ago

We are also affected by the same issue, crashes started spiking recently without any reason.

The only fix seems to be to not call Phrase.getDelegate() on the activity. It is not reproducible on every device and depends on the webview version

When a fix can be expected ?

hahmed-dev commented 2 months ago

The latest release 3.10.0, includes fixes for crashes experienced in Webview when opening alert dialogs.

valeriiia commented 2 weeks ago

The 3.10.1 release solved the problem indeed. However, I see the following information about the next 3.10.2 release " Bugfixes: Reverts changes introduced in release 3.10.1 which can potentially lead to app crashing. " Does it mean that fix for crashes experienced in Webview are back again? Could you please clarify it?

hahmed-dev commented 2 weeks ago

Hi @valeriiia actually the after 3.10.0 there were still some reports of this issue appearing in Xiaomi devices. A potential fix was made in 3.10.1 which caused some regression. Hence, we have just reverted the fix made in 3.10.1, fixes that were shipped in 3.10.0 should still work.