7647615f-5c59-4224-884a-06b2ae3c75a1
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.get(ArrayList.java:437)
at mozilla.components.browser.search.SearchEngineManager.getProvidedDefaultSearchEngineAsync(SearchEngineManager.kt:7)
at mozilla.components.browser.search.SearchEngineManager.getDefaultSearchEngineAsync(SearchEngineManager.kt:7)
at mozilla.components.browser.search.SearchEngineManager$getDefaultSearchEngineAsync$1.invokeSuspend(Unknown Source:12)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:3)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:21)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:1)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:11)
`
Reproducing the crash with Samsung Galaxy S9 (Android 8) on Nightly 9/8 this issue is similar to the crash mentioned here #8406
Well.. this is interesting..
I don't think the user should ever get into the situation in which she can delete all search engines.
Or maybe if that's the case we should just re-add a default one because otherwise how would search work anymore?
But what if there is not a default one for the locale?
For your information, I note the background of my encounter with this crash. Its numbers correspond to the reproducing procedure.
When you open firefox for the first time you have a set of default search engines for your locale. If the user somehow is able to delete all search engines (which leaves the browser in a inconsistent state) a failsafe should trigger to 'install' the default set of locales again.
Restoring all locales will avoid the issue to choose a default one (the browser should have a non empty set for any locale, so no need to change or choose anything) and although the user manually deleted them, they managed to delete all of them, so it should not come as a surprise.
But if that's a concern perhaps a small toast or a dialog could popup like "all search engine were deleted, defaults restored". This is a failsafe for a very particular sequence of steps anyway.
Pinging @brampitoyo for search feedback
@Mugurell @TrianguloY @hokonch I think the right approach is to disallow removing search engine, if there鈥檚 only one engine remaining on the list.
This means that the last search engine 鈥撀爓hatever it may be 鈥撀燾annot ever be removed. And people won鈥檛 ever be stuck with 鈥渮ero鈥澛爏earch engine installed.
What do you think?
FWIW Firefox for desktop has the same behaviour as suggested by @brampitoyo - the last remaining search engine cannot be removed.
That's already a feature, you can't delete the last search engine when there is only one. If you check the steps you will see that the bug happens because when changing locales firefox changes the default search engines too.
So a real fix should be something like don't change the search engines when changing locales.
But then maybe in a few weeks another user discovers another unintended behaviour that also allows you to remove all search engines, you fix that, and then a third steps is found, etc. Or what if somehow a user data is corrupted?
The list of search engines is a list, so firefox needs to be prepared to manage it when there is no items there, even if that's 'normally' impossible.
That's why I mentioned the failsafe, with the (in my opinion) better approach to simply restore the default engines as if 'something bad happened, let me restore you the default list'
another unintended behaviour that also allows you to remove all search engines
Upgrade Firefox 80 whose all engines deleted except for Twitter
Thank you all for chiming in!
Based on the feedback here looks like we should have a fallback in adding back
the default engine / first available for that locale
if otherwise the list of engines would be empty.
FWIW, I've just hit this in Fennec 81.1.3 (it wasn't a problem in 81.1.1) and although I did remove all the pre-configured search engines, I still have a custom one.
foobar:/data/data/org.mozilla.fennec_fdroid/shared_prefs # cat fenix-search-engine-provider.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<set name="fenix-installed-search-engines-en-CA-CA-fallback">
<string>DuckDuckGo Lite</string>
</set>
</map>
foobar:/data/data/org.mozilla.fennec_fdroid/shared_prefs # cat custom-search-engines.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<set name="pref_custom_search_engines">
<string>DuckDuckGo Lite</string>
</set>
<string name="DuckDuckGo Lite"><?xml version="1.0" encoding="UTF-8"?><OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"><ShortName>DuckDuckGo Lite</ShortName><Image width="16" height="16">data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAAAXNSR0IArs4c6QAAAARzQklUCAgI CHwIZIgAAAGaSURBVHic7dw/TgJBGEDxb/wTjcSahsTEyoorGEoqOuMBtvAYVl7Bxk5L7Cg5gIkJ xcTSgppwBy2ElWCz0V1eNr5ftUO2+DKP2Wohxbb+w8ePz1SfXKTN5ffCjd+tVYivAG4+Ixdpj57h v0t++1meAJgBYAaAGQBmAJgBYAaAGQBmAJgBYAaAGQBmAJgBYAaAGQBmAJgBYAaAGQBmAJgBYAaA GQBmAJgBYAaAGQBmANgBPUAVpyeH8Xh3Wa6fJu8xns65gWrUigDHR/sxGpyV69e3JThNvXwEwQwA MwDMADADwAwAMwDMADADwAwAMwDMADADwAwAMwDMADADwAwAMwDMADADwFrxVsS2m6uLuB6eV77/ eTqP2/tZgxP9XisD9Lqd6HU7le9/yYsGp/kbH0Ew/zcU5gmAGQBmAJgBYAaAGQBmAJgBYAaAGQBm AJgBYAaAGQBmAJgBYAaAGQBmAJgBYAaAGQBmAJgBYAaAGQBmAJgBYAaAGQBmAFiKiPA3ApBcJE8A LJVXnoLdykWK2AywZohmrTZ+7RNY+Sh2/K4PjAAAAABJRU5ErkJggg== </Image><Description>DuckDuckGo Lite</Description><Url type="text/html" template="https://lite.duckduckgo.com/lite?q={searchTerms}"/></OpenSearchDescription></string>
</map>
md5-7b9a5b1d05ca63ca645ef018eafe2116
10-13 18:19:03.204 E/AndroidRuntime(28255): java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
10-13 18:19:03.204 E/AndroidRuntime(28255): at java.util.ArrayList.get(ArrayList.java:437)
10-13 18:19:03.204 E/AndroidRuntime(28255): at mozilla.components.browser.search.SearchEngineManager.getProvidedDefaultSearchEngineAsync(SearchEngineManager.kt:7)
10-13 18:19:03.204 E/AndroidRuntime(28255): at mozilla.components.browser.search.SearchEngineManager.getDefaultSearchEngineAsync(SearchEngineManager.kt:7)
10-13 18:19:03.204 E/AndroidRuntime(28255): at mozilla.components.browser.search.SearchEngineManager$getDefaultSearchEngineAsync$1.invokeSuspend(Unknown Source:12)
10-13 18:19:03.204 E/AndroidRuntime(28255): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:3)
10-13 18:19:03.204 E/AndroidRuntime(28255): at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:21)
10-13 18:19:03.204 E/AndroidRuntime(28255): at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:1)
10-13 18:19:03.204 E/AndroidRuntime(28255): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:11)
10-13 18:19:03.208 W/ActivityTaskManager( 669): Force finishing activity org.mozilla.fennec_fdroid/org.mozilla.fenix.HomeActivitycom.android.systemui.media.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:163)
@baldurmen same situation that you
This seems to have been fixed in the latest Nightly.
Cannot reproduce the crash due to the fact that the user cannot delete all the search engines.
Environment:
You just needed to add custom engines and delete all the defaults. In last version is solved the issue though.
The issue is present until 81.1.5 and solved in the next version.