question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullPointerException crash involving initial state of keyboard logic

See original GitHub issue

Short description

Can’t really tell what I did to crash it but I basically updated to alpha4, opened the app drawer in Lawnchair and tried to instantly type after it opened the keyboard. I can’t reproduce it again but I hope the stack trace is helpful anyway. Maybe it has something to do with a setting so if you need any additional informatiom just ask.

Steps to reproduce

  1. Set Lawnchair to automatically show the keyboard on app drawer open
  2. Swipe up and instantly type
  3. See crash

Environment information

  • FlorisBoard 0.4.0-alpha03 (89)
  • Device: OnePlus KB2003 (OnePlus8T_EEA)
  • Android: 11 (cn=R sdk=30)

Attached logs and stacktrace files

Detailed info (Debug log header)
======= SYSTEM INFO =======
Time                : 2022-08-28T20:07:58.646Z
Manufacturer        : OnePlus
Model               : KB2003
Product             : OnePlus8T_EEA
Android             : 11 (cn=R sdk=30) [lineage_kebab-userdebug 11 RQ3A.211001.001 eng.root.20220817.180712 dev-keys]
ABIs                : [arm64-v8a, armeabi-v7a, armeabi]
Memory              : 4.20 GiB (57.28% used, 7.34 GiB max)
Font scale          : 1.0
Locales             : en-US,de-DE

======= APP INFO =======
Package             : dev.patrickgold.florisboard.beta
Name                : FlorisBoard Beta
Version             : 0.4.0-alpha03 (89)
Build type          : beta
Build commit hash   : 26650d2a00d509efbbd58bafa8606ba11bc5961f
Java heap memory    : 34.29 MiB (13.39% used, 256.00 MiB max)
Native heap memory  : 28.43 MiB (90.42% used, 31.44 MiB max)

======= FEATURE CONFIG =======
Smartbar enabled            : true
Suggestions enabled         : false
Inline autofill enabled     : true
Glide enabled               : false
Internal clipboard enabled  : false

1661717267554.stacktrace
java.lang.NullPointerException
	at dev.patrickgold.florisboard.lib.StateAdaptersKt.observeAsNonNullState(StateAdapters.kt:10)
	at dev.patrickgold.florisboard.ime.keyboard.KeyboardManager.observeActiveState(Unknown Source:11)
	at dev.patrickgold.florisboard.FlorisImeService.access$ImeUi(FlorisImeService.kt:3)
	at dev.patrickgold.florisboard.FlorisImeService$ImeUiWrapper$1$1$1$1.invoke(FlorisImeService.kt:73)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at dev.patrickgold.florisboard.ime.theme.FlorisImeThemeKt$FlorisImeTheme$1$1.invoke(FlorisImeTheme.kt:2)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:3)
	at dev.patrickgold.florisboard.ime.theme.FlorisImeThemeKt$FlorisImeTheme$1.invoke(FlorisImeTheme.kt:13)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at androidx.compose.material.MaterialTheme_androidKt.PlatformMaterialTheme(MaterialTheme.android.kt:4)
	at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:2)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:3)
	at androidx.compose.material.TextKt.ProvideTextStyle(Text.kt:6)
	at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:6)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:3)
	at androidx.compose.material.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:132)
	at dev.patrickgold.florisboard.ime.theme.FlorisImeThemeKt.FlorisImeTheme(FlorisImeTheme.kt:32)
	at dev.patrickgold.florisboard.FlorisImeService$ImeUiWrapper$1$1$1.invoke(FlorisImeService.kt:4)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:3)
	at dev.patrickgold.florisboard.FlorisImeService$ImeUiWrapper$1$1.invoke(FlorisImeService.kt:7)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at dev.patrickgold.florisboard.ime.keyboard.FlorisImeSizingKt$ProvideKeyboardRowBaseHeight$2.invoke(FlorisImeSizing.kt:2)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:3)
	at dev.patrickgold.florisboard.ime.keyboard.FlorisImeSizingKt.ProvideKeyboardRowBaseHeight(FlorisImeSizing.kt:116)
	at dev.patrickgold.florisboard.FlorisImeService$ImeUiWrapper$1.invoke(FlorisImeService.kt:4)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at dev.patrickgold.florisboard.lib.compose.ResourcesKt$ProvideLocalizedResources$1.invoke(Resources.kt:2)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:3)
	at dev.patrickgold.florisboard.lib.compose.ResourcesKt.ProvideLocalizedResources(Resources.kt:11)
	at dev.patrickgold.florisboard.FlorisImeService.access$ImeUiWrapper(FlorisImeService.kt:3)
	at dev.patrickgold.florisboard.FlorisImeService$ComposeInputView.Content(FlorisImeService.kt:4)
	at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:2)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:3)
	at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:23)
	at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:8)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:3)
	at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:88)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:4)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:3)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:23)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:6)
	at kotlin.LazyKt__LazyJVMKt.invokeComposable(LazyJVM.kt:2)
	at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:5)
	at kotlin.text.UStringsKt.observeDerivedStateRecalculations(UStrings.kt:8)
	at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:22)
	at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:10)
	at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:7)
	at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:3)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:15)
	at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:2)
	at androidx.compose.ui.platform.WrappedComposition.setContent(Unknown Source:12)
	at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:5)
	at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:3)
	at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:13)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:11)
	at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:17)
	at android.view.View.dispatchAttachedToWindow(View.java:20479)
	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3489)
	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
	at android.view.ViewGroup.addViewInner(ViewGroup.java:5278)
	at android.view.ViewGroup.addView(ViewGroup.java:5064)
	at android.view.ViewGroup.addView(ViewGroup.java:5036)
	at android.inputmethodservice.InputMethodService.setInputView(InputMethodService.java:1920)
	at android.inputmethodservice.InputMethodService.updateInputViewShown(InputMethodService.java:1755)
	at android.inputmethodservice.InputMethodService.prepareWindow(InputMethodService.java:2182)
	at android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java:2131)
	at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(InputMethodService.java:750)
	at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInputWithToken(InputMethodService.java:722)
	at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:226)
	at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:44)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:223)
	at android.app.ActivityThread.main(ActivityThread.java:7664)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
patrickgoldcommented, Aug 29, 2022

Above commit/PR should fix the issue, I now completely swapped the observer logic of KeyboardState from Android’s LiveData to Kotlin’s StateFlow, which should help eliminate these dangling initial null references which cause this crash. This fix will be parts of the 0.4.0-alpha04 release.

@D3SOX @keatit71 @noesterle If possible, could some of you try out the debug artifact of said PR to test if you can produce it in any way? The debug artifact installs independently from beta and stable, you can uninstall it after testing again.

1reaction
patrickgoldcommented, Aug 29, 2022

Thanks for your bug report!

I haven’t been able to reproduce this crash at all, but I think I know where the source is. Will experiment later on with changing the observer logic, so this crash cannot occur anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gradle debug Crashes with NullpointerException - Run works ...
Gradle crashes with a NullpointerException when trying to debug my app in Android Studio. It works fine just to Run the app.
Read more >
How to Fix and Avoid NullPointerException in Java - Rollbar
The NullPointerException occurs due to a situation in application code where an uninitialized object is attempted to be accessed or modified.
Read more >
How to resolve the java.lang.NullPointerException - Educative.io
NullPointerException is thrown when a reference variable is accessed (or de-referenced) and is not pointing to any object. This error can be resolved...
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
When we run the above program, it throws the following NullPointerException error message. Exception in thread "main" java.lang.
Read more >
Runtime errors | AnyLogic Help
If a simulation error occurs, AnyLogic stops the model and notifies the user with an error message. Throwing runtime errors. You can debug...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found