Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[App Crash] activeSurvey is null #2815

Open
anandwana001 opened this issue Nov 10, 2024 · 4 comments · May be fixed by #2890
Open

[App Crash] activeSurvey is null #2815

anandwana001 opened this issue Nov 10, 2024 · 4 comments · May be fixed by #2890
Assignees
Labels
type: bug Something isn't working
Milestone

Comments

@anandwana001
Copy link
Collaborator

 Fatal Exception: java.lang.IllegalArgumentException: Required value was null.
       at com.google.android.ground.ui.datacollection.DataCollectionViewModel.<init>(DataCollectionViewModel.kt:100)
       at com.google.android.ground.DaggerGroundApplication_HiltComponents_SingletonC$ViewModelCImpl$SwitchingProvider.get(DaggerGroundApplication_HiltComponents_SingletonC.java:1465)
       at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory$2.createViewModel(HiltViewModelFactory.java:132)
       at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory$2.create(HiltViewModelFactory.java:103)
       at dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:170)
       at androidx.lifecycle.ViewModelProvider$Factory.create(ViewModelProvider.android.kt:158)
       at androidx.lifecycle.viewmodel.ViewModelProviderImpl_androidKt.createViewModel(ViewModelProviderImpl.android.kt:34)
       at androidx.lifecycle.viewmodel.ViewModelProviderImpl.getViewModel$lifecycle_viewmodel_release(ViewModelProviderImpl.kt:65)
       at androidx.lifecycle.viewmodel.ViewModelProviderImpl.getViewModel$lifecycle_viewmodel_release$default(ViewModelProviderImpl.kt:47)
       at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.android.kt:91)
       at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:51)
       at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:35)
       at com.google.android.ground.ui.datacollection.DataCollectionFragment.getViewModel(DataCollectionFragment.kt:55)
       at com.google.android.ground.ui.datacollection.DataCollectionFragment.onViewCreated(DataCollectionFragment.kt:86)
       at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3152)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:608)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:286)
       at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:114)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1675)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3259)
       at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:3170)
       at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3153)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:608)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:286)
       at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:114)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1675)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3259)
       at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:3177)
       at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:263)
       at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:350)
       at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
       at com.google.android.ground.AbstractActivity.onStart(AbstractActivity.kt:53)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1455)
       at android.app.Activity.performStart(Activity.java:8105)
       at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3745)
       at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:222)
       at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:202)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:174)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:201)
       at android.os.Looper.loop(Looper.java:288)
       at android.app.ActivityThread.main(ActivityThread.java:7996)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:553)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
        
@anandwana001 anandwana001 added the type: bug Something isn't working label Nov 10, 2024
@gino-m
Copy link
Collaborator

gino-m commented Nov 19, 2024

This crash occurerd 20 times in the last 30 days, all from DataCollectionViewModel, but with no crash keys set. This implies that the crash occurred outside of the normal app lifecycle, perhaps after a draft was restored after the app was killed. Filing as P1.

@gino-m
Copy link
Collaborator

gino-m commented Nov 25, 2024

The crash occurs here:

  private val activeSurvey: Survey = requireNotNull(surveyRepository.activeSurvey)

This sounds like a race condition because we're using a synchronous call to activeSurvey, which may not have been initialized yet when the view is being restored. Likely happening after the app is killed and restarted during data collection.

@anandwana001 anandwana001 linked a pull request Dec 1, 2024 that will close this issue
@anandwana001 anandwana001 moved this from Todo to In Progress in Ground Dec 1, 2024
@kenstershiro
Copy link
Collaborator

Suggestion from @gino-m for the race condition, given the load from db should be very fast, it's ok to block the UI to wait for this for now.

@kenstershiro kenstershiro added this to the GA release milestone Dec 4, 2024
@gino-m
Copy link
Collaborator

gino-m commented Dec 12, 2024

@anandwana001 That might look something like this:

 private val activeSurvey: Survey = runBlocking { surveyRepository.activeSurveyFlow.filterNotNull().first() }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants