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

IllegalStateException: Can't access the Fragment View's LifecycleOwner for SignupConfirmationFragment{af01f} (a7a7d9d8-0... #20221

Closed
sentry-io bot opened this issue Feb 20, 2024 · 6 comments · Fixed by #20240

Comments

@sentry-io
Copy link

sentry-io bot commented Feb 20, 2024

Sentry Issue: WORDPRESS-ANDROID-2VEC

java.lang.IllegalStateException: Can't access the Fragment View's LifecycleOwner for SignupConfirmationFragment{156474} (217fd094-2478-49f0-a5c3-6439dde9c763 id=0x7f0a0393 tag=signup_confirmation_fragment_tag) when getView() is null i.e., before onCreateView() or after onDestroyView()
    at androidx.fragment.app.Fragment.getViewLifecycleOwner(Fragment.java:385)
    at org.wordpress.android.login.SignupConfirmationFragment.onCreate(SignupConfirmationFragment.kt:82)
    at androidx.fragment.app.Fragment.performCreate(Fragment.java:3094)
    at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:504)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:268)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1839)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
    at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:565)
    at android.os.Handler.handleCallback(Handler.java:899)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:241)
    at android.app.ActivityThread.main(ActivityThread.java:7888)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:512)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:998)
@thomashorta
Copy link
Contributor

thomashorta commented Feb 20, 2024

This crash is happening on WordPress-Android version 24.3-rc-1, which is currently in beta, so even though it only affected 2 sessions of a single user, it is considered a blocker.

The code that is crashing was introduced recently in wordpress-mobile/WordPress-Login-Flow-Android#131, and I didn't do a thorough investigation but I believe the problem here is using the Fragment's viewLifecycleOwner inside onCreate, before the Fragment View has been created.

It's worth investigating the problem but I guess that possible solutions would be:

  • Using the Activity as Lifecycle Owner (though it might not make sense since it looks like we want to add the MenuProvider at the Fragment's Resume Lifecycle state, and not the Activity's)
  • Moving that line to onViewCreated, which is guaranteed to happen after we have a View, and its LifecycleOwner (though I am not sure about the implications of that since I'm not too familiar with the addMenuProvider API).
  • Use the method signature that doesn't depend on Lifecycle

@thomashorta thomashorta transferred this issue from wordpress-mobile/WordPress-Login-Flow-Android Feb 20, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Feb 20, 2024

Thanks for reporting! 👍

@ThomazFB
Copy link
Contributor

Thanks for the details, @thomashorta. From what I see, your assessment of the issue is correct. While I moved forward with the deprecated migration, keeping the exact entry points for the menu provider registration, I ended up disregarding the availability of the viewLifecycleOwner.

I believe we should go with this approach:

Moving that line to onViewCreated, which is guaranteed to happen after we have a View, and its LifecycleOwner (though I am not sure about the implications of that since I'm not too familiar with the addMenuProvider API).

I'll start reproducing the issue and check if this assumption fixes it. I'll be looping back soon.

@ThomazFB
Copy link
Contributor

PR with the fix available: wordpress-mobile/WordPress-Login-Flow-Android#142. Once we merge it, we can move forward with the beta hotfix for the apps.

Copy link
Author

sentry-io bot commented Feb 26, 2024

Sentry Issue: JETPACK-ANDROID-JQJ

Copy link
Author

sentry-io bot commented Feb 26, 2024

Sentry Issue: WORDPRESS-ANDROID-2VEC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment