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

Duplicate messages can occur when two campaigns are triggered by different events in In-App Messaging #9070

Closed
kouki-dan opened this issue Dec 9, 2021 · 6 comments
Labels
Milestone

Comments

@kouki-dan
Copy link

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 13.1
  • Firebase SDK version: 8.10.0
  • Installation method: Swift Package Manager
  • Firebase Component: In-App Messaging
  • Target platform(s): iOS

[REQUIRED] Step 2: Describe the problem

Duplicate messages can occur when two campaigns are triggered by different events. (The first message must have an image to reproduce it.)

Setup like this in the console.

First Event Second Event
スクリーンショット 2021-12-09 23 07 04 スクリーンショット 2021-12-09 23 07 35

And trigger events consecutively like this code.

struct ContentView: View {
    var body: some View {
        Button("Trigger In-App") {
            InAppMessaging.inAppMessaging().triggerEvent("first_event")
            InAppMessaging.inAppMessaging().triggerEvent("second_event")
        }
            .padding()
    }
}

It shows multiple dialogs in a row.

2021-12-09.23.03.34.mov

It seems FIRIAMDisplayExecutor checks message is displayed or not in this code.

if (self.isMsgBeingDisplayed) {
FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM400008",
@"An in-app message display is in progress, do not check analytics event "
"based message for now.");
return;
}

However, isMsgBeingDisplayed becomes true only after the image has finished loading.

I think if another event is triggered while loading the image in a first event, two dialogs are shown in the order in which the images were loaded.

And _currentMsgBeingDisplayed is set as last called displayForMessage. The last event(In this video, second event) may be treated as displayed.

- (void)recordValidImpression:(NSString *)messageID withMessageName:(NSString *)messageName {
if (!self.impressionRecorded) {
[self.displayBookKeeper
recordNewImpressionForMessage:messageID
withStartTimestampInSeconds:[self.timeFetcher currentTimestampInSeconds]];
self.impressionRecorded = YES;
[self.messageCache removeMessageWithId:messageID];
// Log an impression analytics event as well.
[self.analyticsEventLogger
logAnalyticsEventForType:FIRIAMAnalyticsEventMessageImpression
forCampaignID:messageID
withCampaignName:messageName
eventTimeInMs:nil
completion:^(BOOL success) {
FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM400007",
@"Logging analytics event for impression %@",
success ? @"succeeded" : @"failed");
}];
}
}

Therefore, on the second tap in this video, it shows the first event.

I think the first tap will give me a first event message, and the second tap will give me a second event message.

Steps to reproduce:

  • Set two campaigns with another event trigger and it has an image.
  • Trigger events consecutively.

Minimum reproduce project is here: https://github.com/kouki-dan/InAppMessaging-Duplicate

@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.
@rizafran rizafran added api: inappmessaging Firebase In App Messaging and removed needs-triage labels Dec 9, 2021
@rizafran
Copy link
Contributor

Sorry for the late reply, @kouki-dan. I was able to reproduce the same behavior. Let me check with the team if it's intended or a bug. Thanks.

@rizafran
Copy link
Contributor

@kouki-dan, our engineers have been notified and will look into this. This is internally tracked in b/211895119. Thanks.

@eldhosembabu
Copy link
Contributor

This issue should be fixed in PR : #9138

@paulb777 paulb777 added this to the 8.11.0 - M110 milestone Dec 23, 2021
eldhosembabu added a commit that referenced this issue Jan 5, 2022
…y different events (#9138)

* [fixed] Duplicate messages can occur when two campaigns are triggered by different events in In-App Messaging (#9070).
@eldhosembabu
Copy link
Contributor

Closing this issue since fix is merged. You can expect to see the fix in next release of SDK.

@kouki-dan
Copy link
Author

Thank you!

leotianlizhan pushed a commit that referenced this issue Feb 1, 2022
…y different events (#9138)

* [fixed] Duplicate messages can occur when two campaigns are triggered by different events in In-App Messaging (#9070).
@firebase firebase locked and limited conversation to collaborators Feb 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
5 participants