Skip to content

Host activity interrupted error & dialog dismissal #3341

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

Merged
merged 14 commits into from
Jan 30, 2022

Conversation

rachaprince
Copy link

@rachaprince rachaprince commented Jan 21, 2022

This PR makes it so that if the host activity is interrupted and put on pause then we want for it to resume to show a dialog. If there is a new activity that resumes then we cancel the task.


@GuardedBy("cachedNewReleaseLock")
private AppDistributionReleaseInternal cachedNewRelease;
AtomicReference<AppDistributionReleaseInternal> cachedNewRelease = new AtomicReference();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this had a separate lock from the cached task, I thought we could reduce the number of blocks by adding an atomic reference

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jan 21, 2022

Coverage Report 1

Affected Products

  • firebase-appdistribution

    Overall coverage changed from 76.31% (c35626a) to 76.45% (0d688a6) by +0.14%.

    FilenameBase (c35626a)Merge (0d688a6)Diff
    FirebaseAppDistribution.java95.60%94.44%-1.16%
    FirebaseAppDistributionException.java88.24%88.57%+0.34%
    FirebaseAppDistributionLifecycleNotifier.java72.53%73.68%+1.16%

Test Logs

Notes

  • Commit (0d688a6) is created by Prow via merging PR base commit (c35626a) and head commit (24b1ff4).
  • Run gradle <product>:checkCoverage to produce HTML coverage reports locally. After gradle commands finished, report files can be found under <product-build-dir>/reports/jacoco/.

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/oakBUUBwqr.html

@google-oss-bot
Copy link
Contributor

The public api surface has changed for the subproject firebase-appdistribution:
error: Added enum constant com.google.firebase.appdistribution.FirebaseAppDistributionException.Status.HOST_ACTIVITY_INTERRUPTED [AddedField]

Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jan 21, 2022

Size Report 1

Affected Products

  • firebase-appdistribution

    TypeBase (c35626a)Merge (0d688a6)Diff
    aar123 kB124 kB+548 B (+0.4%)
    apk (aggressive)743 kB743 kB+280 B (+0.0%)
    apk (release)1.55 MB1.55 MB+500 B (+0.0%)

Test Logs

Notes

  • Commit (0d688a6) is created by Prow via merging PR base commit (c35626a) and head commit (24b1ff4).

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/YSu5cASYJ0.html

@manny-jimenez
Copy link
Contributor

Wanted to get this up before EOD still needs some cleaning before review

@google-oss-bot
Copy link
Contributor

The public api surface has changed for the subproject firebase-appdistribution:
error: Added enum constant com.google.firebase.appdistribution.FirebaseAppDistributionException.Status.HOST_ACTIVITY_INTERRUPTED [AddedField]

Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.

if (dialogHostActivityHasChanged(activity)) {
setUpdateIfNewReleaseWithHostError();
} else {
signInConfirmationDialog.show();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lfkellogg Would like to discuss this with you. If we kept the past implementation of calling the method the task hangs on failure. If we set the task to fail then if the user has some failure listener that will be called. I believe we ran into this before not sure if there was a resolution.


return showUpdateDialogTask.getTask();
}

private void setRemakeDialogsToFalse() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're just using this in one place, and it's already being called from a synchronized block, we might as well just inline it.

private boolean remakeUpdateDialog = false;
@Nullable private Activity dialogHostActivity = null;

@GuardedBy("updateIfNewReleaseTaskLock")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think either of these booleans need to be protected by this lock, or any other lock. They're almost always read or written from the main thread (in lifecycle callbacks), and in the case where they're being set to false in updateIfNewReleaseAvailable, it won't practically affect anything because there's no task in progress at that point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true I agree calling the updateIfNewRelease would not be an issue. I don't see a problem with onPause being called multiple times from different places but if those are all on the main thread there shouldn't be a deadlock issue so as long as we are sure of that we can change it.


private void updateConfirmationDialogClosedCallback(TaskCompletionSource showUpdateDialogTask) {
synchronized (updateIfNewReleaseTaskLock) {
remakeUpdateConfirmationDialog = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this anymore, right? I'd just drop it and inline this method.

Copy link
Contributor

@manny-jimenez manny-jimenez Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove for now. We don't have this on signIn but it might be nice to have since it does set the remake variable to false when the dialog is cancelled. That may be unnecessary but it makes sense to set it after that since it does not need to be remade at that point. Curious on your thoughts about that.

@manny-jimenez
Copy link
Contributor

/test smoke-tests

@VisibleForTesting
void onActivityDestroyed(@NonNull Activity activity) {
// If the dialogHostActivity is being destroyed it is set to null. This is to ensure that
// onResume shows the dialog on a configuration change and not check the activity reference
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"and does not check" ? And please put a . on the end of the comment.

}

private boolean awaitingSignInDialogConfirmation() {
return (updateIfNewReleaseAvailableIsTaskInProgress() && remakeSignInConfirmationDialog);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it wouldn't make a practical difference, wouldn't it make more sense if this checked if showSignInDialogTask was in progress, instead of cachedUpdateIfNewReleaseTask?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does make more sense and it shouldn't change anything will change

}

private boolean awaitingUpdateDialogConfirmation() {
return (updateIfNewReleaseAvailableIsTaskInProgress() && remakeUpdateConfirmationDialog);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, but showUpdateDialogTask


assertAlertDialogShown();
assertFalse(updateTask.isComplete());
}

@Test
public void taskCancelledOnDestroy_whenSignInDialogShowing() {
public void
updateIfNewReleaseAvailable_signInTaskCancelled_whenSignInDialogShowingAndNewActivityStarts() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: for this and the next test, could you change the name of the test to put the "when" clause in the middle of the name, and the expected behavior at the end? E.g. updateIfNewReleaseAvailable_whenSignInDialogShowingAndNewActivityStarts_signInTaskCancelled

Copy link
Contributor

@lfkellogg lfkellogg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits, but this looks great!

@lfkellogg lfkellogg changed the title WIP host activity interrupted error & dialog dismissal Host activity interrupted error & dialog dismissal Jan 28, 2022
@google-oss-bot
Copy link
Contributor

@rachaprince: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
smoke-tests 24b1ff4 link /test smoke-tests

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@manny-jimenez manny-jimenez merged commit 66797a8 into master Jan 30, 2022
@manny-jimenez manny-jimenez deleted the fad-add-host-activity-interrupted-error branch January 30, 2022 22:52
@firebase firebase locked and limited conversation to collaborators Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants