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

GooglePayLauncherFragment does not restore local variables when system looses fragment state and restores it #1425

Open
jamesblasco opened this issue Jun 17, 2023 · 9 comments

Comments

@jamesblasco
Copy link
Collaborator

Describe the bug
flutter-stripe/flutter_stripe#1282

One developer is reporting the app breaking on Android with this error

lateteinit property configuration has not been initialized
       at com.reactnativestripesdk.GooglePayLauncherFragment.onViewCreated(GooglePayLauncherFragment.java:29)

It looks like if the app looses state at any point the FragmentManager takes care of restoring the Fragments automatically, but expects the developer to restore the local content of the Fragment, inside the views and variables:
https://developer.android.com/guide/fragments/saving-state

In our case GooglePayLauncherFragment stored several variables with lateinit that are setted up when calling presentGooglePaySheet. After that the Fragment is never removed from the activity and it.
So when the app looses the state the FragmentManager automatically restores the Fragment, calls onViewCreated, and tries to use the variables that have been lost along the way

Smartphone / tablet

Device: Lots of Android phones (Samsung, Google, Oppo, Motorola, etc)
OS: All the way from Android 13 to Android 10

Additional context

Stacktrace:

Fatal Exception: R9.B: lateinit property configuration has not been initialized
       at com.reactnativestripesdk.GooglePayLauncherFragment.onViewCreated(GooglePayLauncherFragment.java:29)
       at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:4)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:6)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:3)
       at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:30)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:27)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:9)
       at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:11)
       at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:4)
       at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:20)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1510)
       at android.app.Activity.performStart(Activity.java:8616)
       at android.app.ActivityThread.handleStartActivity(ActivityThread.java:4204)
       at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
       at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8757)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Desktop (please complete the following information):

  • OS: Android
@HatsuneMikuV
Copy link

I has same issue
image

@leewrigg
Copy link

leewrigg commented Mar 5, 2024

@charliecruzan-stripe - is there an ETA for when this issue will be investigated?

@gabvrodrigues
Copy link

Same issue here

@kissbudai
Copy link

@charliecruzan-stripe Any news on this?

We also face this issue. The issue is connected to state restoration and it can be reproduced for debugging by enabling the 'Don't keep activities' developer option. With that enabled, it happens constantly.

Stacktrace:

kotlin.UninitializedPropertyAccessException: lateinit property configuration has not been initialized
	at com.reactnativestripesdk.GooglePayLauncherFragment.onViewCreated(GooglePayLauncherFragment.kt:41)
	at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3147)
	at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:588)
	at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
	at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:114)
	at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1455)
	at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3034)
	at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2952)
	at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:263)
	at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:350)
	at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1433)
	at android.app.Activity.performStart(Activity.java:7923)
	at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3332)
	at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
	at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	at android.os.Looper.loop(Looper.java:224)
	at android.app.ActivityThread.main(ActivityThread.java:7562)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

@favazHF
Copy link

favazHF commented Oct 11, 2024

Any update of this? thanks!

@leewrigg
Copy link

Steps to reproduce this -

  1. Enable Don't keep activities in the phone's Developer Options settings.
  2. Open your app and view the Google Pay sheet before minimising the app (you can pay it, close the sheet, or simply leave it open).
  3. Minimise your app (with 'don't keep activities' enabled, this kills the activity straight away. Without this option, you'd need to leave it in the background for a while I guess.)
  4. Bring the app back into the foreground. For me, it crashes at this point every time.

@anvemonta
Copy link

Is there any update on this?

@anvemonta
Copy link

@charliecruzan-stripe Is there an ETA for when this will be fixed/investigated? It's quite a severe bug and accounts for the majority of our crashes on Android

@jonasbark
Copy link
Collaborator

jonasbark commented Oct 25, 2024

@charliecruzan-stripe we agree that this issue deserves priority.

The users of our Flutter plugin are facing the same:
flutter-stripe/flutter_stripe#1282

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants