firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

[In-App Messaging] DisplayErrorListener won't be triggered while displaying error in-app messaging.

Open ione0213 opened this issue 2 years ago • 4 comments

[READ] Step 1: Are you in the right place?

  • Yes

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Hedgehog 2023.1.1 Patch 1
  • Firebase Component: In-App Messaging
  • Component version: 32.2.3

[REQUIRED] Step 3: Describe the problem

DisplayErrorListener won't trigger while displaying error in-app messaging.

Steps to reproduce:

  1. Add FirebaseInAppMessagingDisplayErrorListener via FirebaseInAppMessaging.getInstance().addDisplayErrorListener().
  2. Create a new campaign with a jpeg whose format is unsupported and make it display in the app.
  3. DisplayErrorListener won't be triggered while displaying error in-app messaging.

What happened? How can we make the problem occur? This could be a description, log/console output, etc.

We found while the function onLoadFailed was accessed, the inAppMessage and displayCallbacks objects are always null. Hence DisplayErrorListener will never be triggered.

Relevant Code:

@FirebaseAppScope
public class GlideErrorListener implements RequestListener<Object> {
  private InAppMessage inAppMessage;
  private FirebaseInAppMessagingDisplayCallbacks displayCallbacks;

  @Inject
  GlideErrorListener() {}

  public void setInAppMessage(
      InAppMessage inAppMessage, FirebaseInAppMessagingDisplayCallbacks displayCallbacks) {
    this.inAppMessage = inAppMessage;
    this.displayCallbacks = displayCallbacks;
  }

  @Override
  public boolean onLoadFailed(
      @Nullable GlideException e, Object model, Target<Object> target, boolean isFirstResource) {
    Logging.logd("Image Downloading  Error : " + e.getMessage() + ":" + e.getCause());

    if (inAppMessage != null && displayCallbacks != null) {
      if (e.getLocalizedMessage().contains("Failed to decode")) {
        displayCallbacks.displayErrorEncountered(
            FirebaseInAppMessagingDisplayCallbacks.InAppMessagingErrorReason
                .IMAGE_UNSUPPORTED_FORMAT);
      } else {
        displayCallbacks.displayErrorEncountered(
            FirebaseInAppMessagingDisplayCallbacks.InAppMessagingErrorReason
                .UNSPECIFIED_RENDER_ERROR);
      }
    }

    return false;
  }

  @Override
  public boolean onResourceReady(
      Object resource,
      Object model,
      Target<Object> target,
      DataSource dataSource,
      boolean isFirstResource) {
    Logging.logd("Image Downloading  Success : " + resource);
    return false;
  }
}

ione0213 avatar Jan 16 '24 09:01 ione0213

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Jan 16 '24 09:01 google-oss-bot

Hi @ione0213, thank you for reaching out. I tried reproducing the issue, however, I’m quite having a trouble with step no 2 you shared.

Create a new campaign with a jpeg whose format is unsupported and make it display in the app.

Can you share with me how you were able to use an unsupported image? If possible, could you share the image you used? Currently, the image URL link must be a valid HTTPS URL. Only .png and .jpg image formats are supported with 3:2 and/or 1:1 aspect ratio.

Aside from that, could you try using the latest SDK version and see if the issue persists? If so, can you share an MCVE or code snippet?

lehcar09 avatar Jan 16 '24 19:01 lehcar09

Hi @ione0213, thank you for reaching out. I tried reproducing the issue, however, I’m quite having a trouble with step no 2 you shared.

Create a new campaign with a jpeg whose format is unsupported and make it display in the app.

Can you share with me how you were able to use an unsupported image? If possible, could you share the image you used? Currently, the image URL link must be a valid HTTPS URL. Only .png and .jpg image formats are supported with 3:2 and/or 1:1 aspect ratio.

Aside from that, could you try using the latest SDK version and see if the issue persists? If so, can you share an MCVE or code snippet?

@lehcar09 You can create a non-jpeg file(e.g. .log, .txt, or others...). Modify its' filename extension from .log/.txt/... to .jpg. And upload to the campaign.

We've tried using the latest SDK version(com.google.firebase:firebase-bom:32.7.0). It's still not working. screenshot

ione0213 avatar Jan 17 '24 02:01 ione0213

Hi @ione0213, thank you for providing the details. I was able to reproduce the issue you reported. With that, I'll inform our engineers and check what we can do here.

lehcar09 avatar Jan 19 '24 14:01 lehcar09

The fix has been rolled out on BOM version 32.8.0. Kindly update to version BOM 32.8.0 or latest.

I'll go ahead and close this issue now. If you encounter any issue, you can file new issue with the details to help is investigate the issue. Thanks!

lehcar09 avatar Jul 03 '24 11:07 lehcar09