Fenix: NoSuchElementExceptionkotlin.collections.ArraysKt in first fatal List is empty

Created on 26 Jun 2020  路  5Comments  路  Source: mozilla-mobile/fenix

Crash seen on Sentry for Fenix Nightly, has grown in the past two days with hundreds of events.

https://sentry.prod.mozaws.net/operations/fenix-nightly/issues/8870448/?query=is%3Aunresolved

May be related to changes from #9935? or similar to #11906

SearchProvider crash triage

Most helpful comment

I think this is caused by the use of engines.list.first() as a fallback value in getDefaultEngine. cc @boek

/**
 * Returns first element.
 * @throws [NoSuchElementException] if the list is empty.
 */
public fun <T> List<T>.first(): T {
    if (isEmpty())
        throw NoSuchElementException("List is empty.")
    return this[0]
}

Steps to reproduce

  1. Add custom search, like DuckDuckGo (https://duckduckgo.com/?q=%s) (I'm on russian locale, so there's no DDG in default engines)
  2. Delete all other default search engines
  3. Restart browser and see crash

To avoid crash, leave at least one default search engine in list

All 5 comments

I think this is caused by the use of engines.list.first() as a fallback value in getDefaultEngine. cc @boek

/**
 * Returns first element.
 * @throws [NoSuchElementException] if the list is empty.
 */
public fun <T> List<T>.first(): T {
    if (isEmpty())
        throw NoSuchElementException("List is empty.")
    return this[0]
}

I think this is caused by the use of engines.list.first() as a fallback value in getDefaultEngine. cc @boek

/**
 * Returns first element.
 * @throws [NoSuchElementException] if the list is empty.
 */
public fun <T> List<T>.first(): T {
    if (isEmpty())
        throw NoSuchElementException("List is empty.")
    return this[0]
}

Steps to reproduce

  1. Add custom search, like DuckDuckGo (https://duckduckgo.com/?q=%s) (I'm on russian locale, so there's no DDG in default engines)
  2. Delete all other default search engines
  3. Restart browser and see crash

To avoid crash, leave at least one default search engine in list

I made this PR to attempt to address the crash but it certainly doesn't address the cause of the null condition https://github.com/mozilla-mobile/android-components/pull/7531

Can't reproduce on Nightly 200714 06:01. Maybe fixed.

We believe it's been handled by #12544 , please reopen if you see it again after 7/17 Nightly.

Was this page helpful?
0 / 5 - 0 ratings