Android UIKit's BaseFragment isActive() / isFragmentAlive() methods are not comprehensive and still allow crashes

[Problem/Question]

We have made a few customizations and bug fixes to UIKit v2 in our own forked version. We would love to get to a world where we are no longer using a fork. We are exploring moving to UIKit v3. Fortunately, it looks like UIKit v3 has opened up customization enough that we no longer need our own fork for visual changes. Unfortunately, there are some non-visual bug fixes we made in our fork that are still an issue in UIKit v3.

One such issue is in BaseFragment’s check for if the fragment is active / alive. This method is good for checking if a screen is still around when some async callback finally happens.

UIKit v2:

protected boolean isActive() {
    boolean isDeactivated = isRemoving() || isDetached() || getContext() == null;
    return !isDeactivated;
}

UIKit v3:

protected boolean isFragmentAlive() {
    boolean isDeactivated = isRemoving() || isDetached() || getContext() == null;
    return !isDeactivated;
}

Unfortunately, the check is not comprehensive enough and we were seeing crashes. In our fork, we changed the implementation to also check !Fragment.isAdded() as well.

protected boolean isFragmentAlive() {
    boolean isDeactivated = !isAdded() || isRemoving() || isDetached() || getContext() == null;
    return !isDeactivated;
}

[UIKit Version]
UIKit v3
UIKit v2

[Reproduction Steps]
Unfortunately, we no longer have the stack traces of crashes where this was an issue. It was most likely triggered by an async callback whose logic requires the fragment be added, but it has since been removed.

[Current impact]
It isn’t affecting us since we fixed in a forked version of UIKit. Ideally, we wouldn’t need a forked version of UIKit and this bug would be fixed in the original repository.

@stephen-mojo,

It looks like this would be better served by reporting it via the Dashboard as your an organization with a paid support plan. I would suggest relaying this to our support team via your organization’s Sendbird Dashboard.