Closed Bug 2058916 Opened 13 days ago Closed 11 days ago

IllegalArgumentException in HighlightedDomainUrlKt.computeDomainEndScrollValue

Categories

(Firefox for Android :: Toolbar, defect)

All
Android
defect

Tracking

()

RESOLVED FIXED
155 Branch
Tracking Status
firefox153 --- fixed
firefox154 --- fixed
firefox155 --- fixed

People

(Reporter: polly, Assigned: petru)

References

Details

(Keywords: crash, Whiteboard: [fxdroid][android-core] )

Attachments

(6 files)

Crash observed in play store since firefox v153

Exception java.lang.IllegalArgumentException:
  at androidx.compose.ui.text.internal.InlineClassHelperKt.throwIllegalArgumentException (InlineClassHelper.kt:53)
  at androidx.compose.ui.text.MultiParagraph.getPathForRange (MultiParagraph.java:1262)
  at androidx.compose.ui.text.TextLayoutResult.getPathForRange (TextLayoutResult.kt:533)
  at mozilla.components.compose.browser.toolbar.ui.HighlightedDomainUrlKt.computeDomainEndScrollValue (HighlightedDomainUrl.kt:222)
  at mozilla.components.compose.browser.toolbar.ui.HighlightedDomainUrlKt$focusTextIndexRange$2$1$1.invokeSuspend (HighlightedDomainUrl.kt:151)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:34)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:100)
  at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch (AndroidUiDispatcher.android.kt:79)
  at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch (AndroidUiDispatcher.android.kt:41)
  at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run (AndroidUiDispatcher.android.kt:57)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:210)
  at android.os.Looper.loop (Looper.java:299)
  at android.app.ActivityThread.main (ActivityThread.java:8280)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:576)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1073)

looks like this code is throwing, because the index is out of bounds
maybe we need to be more defensive in this calculation

Whiteboard: [fxdroid][android-core]
Assignee: nobody → petru
Status: NEW → ASSIGNED
See Also: → 2056836

buildUrlAnnotatedString logged but still added a LinkAnnotation when the link
text was blank or not found in the full text (indexOf returned -1), producing a
span with a negative start that crashed later in the text layout pass.
Skip such links instead so the text still renders, just without the broken
clickable span. This mainly guards against localized strings whose link
substring drifts out of the full text.

computeDomainEndScrollValue passed the registrable domain indices straight to
getPathForRange, which throws if they are out of range or start > end. Coerce
them so 0 <= startIndex <= endIndex <= text.length always holds, guarding
against a caller supplying a domain span inconsistent with the displayed URL.

This is mostly hardening the changes done for bug 2056836.

Pushed by plingurar@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/dee06f5188a1 https://hg.mozilla.org/integration/autoland/rev/ed69de72aa79 part 1 - Skip LinkText links not found in the full text r=android-reviewers,sfamisa https://github.com/mozilla-firefox/firefox/commit/e5022c041c99 https://hg.mozilla.org/integration/autoland/rev/de36f9398a2e part 2 - Clamp the domain range before measuring the highlighted URL r=android-reviewers,sfamisa
Status: ASSIGNED → RESOLVED
Closed: 11 days ago
Resolution: --- → FIXED
Target Milestone: --- → 155 Branch

The patch landed in nightly and beta is affected.
:petru, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(petru)

Checking what happened over the weekend I see that we haven't had any more of these crash in Nightly while in total we had a few hundreds crashes in beta and a few thousands of crashes in release so with the fix for this being small we should look into uplifting it.

Flags: needinfo?(petru)

buildUrlAnnotatedString logged but still added a LinkAnnotation when the link
text was blank or not found in the full text (indexOf returned -1), producing a
span with a negative start that crashed later in the text layout pass.
Skip such links instead so the text still renders, just without the broken
clickable span. This mainly guards against localized strings whose link
substring drifts out of the full text.

Original Revision: https://phabricator.services.mozilla.com/D315282

Attachment #9621086 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Potential crashes in the toolbar from trying to highlight the URL domain concurrently with the URL being changed.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: no
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing: Issue depends on a race condition - hard to reproduce. We can check the crash reports to assess the impact of the fix.
  • Risk associated with taking this patch: low
  • Explanation of risk level: Small patch which avoids the original crash as per the Google Play statistics without causing other problems.
  • String changes made/needed?: --
  • Is Android affected?: yes
Attachment #9621087 - Flags: approval-mozilla-beta?

computeDomainEndScrollValue passed the registrable domain indices straight to
getPathForRange, which throws if they are out of range or start > end. Coerce
them so 0 <= startIndex <= endIndex <= text.length always holds, guarding
against a caller supplying a domain span inconsistent with the displayed URL.

This is mostly hardening the changes done for bug 2056836.

Original Revision: https://phabricator.services.mozilla.com/D315283

buildUrlAnnotatedString logged but still added a LinkAnnotation when the link
text was blank or not found in the full text (indexOf returned -1), producing a
span with a negative start that crashed later in the text layout pass.
Skip such links instead so the text still renders, just without the broken
clickable span. This mainly guards against localized strings whose link
substring drifts out of the full text.

Original Revision: https://phabricator.services.mozilla.com/D315282

Attachment #9621088 - Flags: approval-mozilla-release?

firefox-release Uplift Approval Request

  • User impact if declined/Reason for urgency: Potential crashes in the toolbar from trying to highlight the URL domain concurrently with the URL being changed.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: no
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing: Issue depends on a race condition - hard to reproduce. We can check the crash reports to assess the impact of the fix.
  • Risk associated with taking this patch: low
  • Explanation of risk level: Small patch which avoids the original crash as per the Google Play statistics without causing other problems.
  • String changes made/needed?: --
  • Is Android affected?: yes
Attachment #9621089 - Flags: approval-mozilla-release?

computeDomainEndScrollValue passed the registrable domain indices straight to
getPathForRange, which throws if they are out of range or start > end. Coerce
them so 0 <= startIndex <= endIndex <= text.length always holds, guarding
against a caller supplying a domain span inconsistent with the displayed URL.

This is mostly hardening the changes done for bug 2056836.

Original Revision: https://phabricator.services.mozilla.com/D315283

Let's assess the crash data in beta first and if it's good, we can uplift in next week dot release.

Attachment #9621086 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9621087 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9621088 - Flags: approval-mozilla-release? → approval-mozilla-release+
Attachment #9621089 - Flags: approval-mozilla-release? → approval-mozilla-release+
QA Whiteboard: [qa-triage-done-c155/b154]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: