android-components icon indicating copy to clipboard operation
android-components copied to clipboard

GeckoRuntimeSettings.setAutomaticFontSizeAdjustment throws IllegalArgumentException

Open st3fan opened this issue 6 years ago • 6 comments

https://sentry.prod.mozaws.net/operations/firefox/issues/9258240

Unable to create application org.mozilla.fenix.MigratingFenixApplication: java.lang.IllegalArgumentException: fontSizeFactor cannot be < 0

java.lang.IllegalArgumentException: fontSizeFactor cannot be < 0
    at org.mozilla.geckoview.GeckoRuntimeSettings.setFontSizeFactorInternal(GeckoRuntimeSettings.java:6)
    at org.mozilla.geckoview.GeckoFontScaleListener.onSystemFontScaleChange(GeckoFontScaleListener.java:3)
    at org.mozilla.geckoview.GeckoFontScaleListener.start(GeckoFontScaleListener.java:6)
    at org.mozilla.geckoview.GeckoFontScaleListener.onEnabledChange(GeckoFontScaleListener.java:3)
    at org.mozilla.geckoview.GeckoFontScaleListener.setEnabled(GeckoFontScaleListener.java:3)
    at org.mozilla.geckoview.GeckoRuntimeSettings.setAutomaticFontSizeAdjustment(GeckoRuntimeSettings.java:1)
    at mozilla.components.browser.engine.gecko.GeckoEngine$settings$1.setAutomaticFontSizeAdjustment(GeckoEngine.kt:1)
    at mozilla.components.browser.engine.gecko.GeckoEngine.<init>(GeckoEngine.kt:25)
    at org.mozilla.fenix.components.Core$engine$2.invoke(Core.kt:15)
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:6)
    at org.mozilla.fenix.components.Core.getEngine(Core.kt)
    at org.mozilla.fenix.FenixApplication.setupInMainProcessOnly(FenixApplication.kt:23)
    at org.mozilla.fenix.MigratingFenixApplication.setupInMainProcessOnly(MigratingFenixApplication.kt:7)
    at org.mozilla.fenix.FenixApplication.onCreate(FenixApplication.kt:7)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4628)
    at android.app.ActivityThread.access$1500(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5345)
    at java.lang.reflect.Method.invoke(Method.java)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)

java.lang.RuntimeException: Unable to create application org.mozilla.fenix.MigratingFenixApplication: java.lang.IllegalArgumentException: fontSizeFactor cannot be < 0
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4631)
    at android.app.ActivityThread.access$1500(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5345)
    at java.lang.reflect.Method.invoke(Method.java)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)

┆Issue is synchronized with this Jira Task

st3fan avatar Jul 30 '20 11:07 st3fan

@agi90 I also filed this here because we may swallow this exception in A-C short term. (If possible) So that we don't have to complicate things with a new GV build.

My worry about this crash is two things:

  • it is a startup crash that you cannot escape from
  • it may be common for people who use a bigger text size on their device, which could also relate to a11y settings

It is a bit odd that we only see it for Android 5.1, but that is still a pretty large segment that we cannot ignore. The number of users is relatively low right now, but that may of course go up in a very big way the coming weeks.

st3fan avatar Jul 30 '20 11:07 st3fan

Following the stacktrace down into GeckoView I see that:

  • We enable automatic font size adjustments
  • GeckoView reads the font_scale system setting
  • This value is passed to setFontSizeFactorInternal
  • Now it gets validated and GV throws IllegalArgumentException if the value is lower than 0.

We can try to catch that in our automaticFontSizeAdjustment wrapper. The result of that would be no crash, but no automatic font size adjustment working. Which seems acceptable.

However: GeckoView also registers a listener to retrieve a new value from the system if it changes. So there is still a chance of us crashing whenever GeckoView retrieves this value via the listener at some point. AC is not involved in that and can't intercept that.

Nevertheless it seems worth trying.

pocmo avatar Jul 30 '20 12:07 pocmo

Android itself handles this case too and maps values < 0 back to 1.0: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/provider/Settings.java;l=3033-3037;drc=957f0a5285b20fdfde96278070ec19633516ebf9

pocmo avatar Jul 30 '20 12:07 pocmo

Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1656078

pocmo avatar Jul 30 '20 12:07 pocmo

It is a bit odd that we only see it for Android 5.1, but that is still a pretty large segment that we cannot ignore. The number of users is relatively low right now, but that may of course go up in a very big way the coming weeks.

This is only happening on older Androids because newer ones handle this case internally (see @pocmo 's response)

agi90 avatar Jul 30 '20 17:07 agi90

We tried to reproduce the issue on the latest Migration build 79.0.2 but we were unable to.

Devices used:

  • Samsung Galaxy Tab A6 (Android 5.1.1)
  • Xiaomi Mi Pad 2 (Android 5.1.1)
  • Galaxy Nexus 4 (Android 5.1.1)

LaurentiuApahideanSV avatar Aug 03 '20 11:08 LaurentiuApahideanSV