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

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

Open
ione0213 opened this issue Jan 16, 2024 · 4 comments
Labels
api: inappmessaging type: bug Something isn't working

Comments

@ione0213
Copy link

[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;
  }
}

@google-oss-bot
Copy link
Contributor

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

@ione0213 ione0213 changed the title [In-App Messaging] DisplayErrorListener won't be trigger while displaying error in-app messaging. [In-App Messaging] DisplayErrorListener won't be triggered while displaying error in-app messaging. Jan 16, 2024
@lehcar09
Copy link

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?

@ione0213
Copy link
Author

ione0213 commented Jan 17, 2024

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

@lehcar09
Copy link

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 lehcar09 added the type: bug Something isn't working label Feb 6, 2024
jadenlin-g added a commit that referenced this issue Feb 21, 2024
…#5719)

Changed `GlideErrorListener` to a normal class and pass a new instance
of the listener into each load image request instead of being injected
as a defaultRequestListener.

Refactored `InAppMessage` and `FirebaseInAppMessagingDisplayCallbacks`
assignment code for clarity.

Internal tracking: b/321732964

Issue: #5644
mrober pushed a commit that referenced this issue Feb 28, 2024
…#5719)

Changed `GlideErrorListener` to a normal class and pass a new instance
of the listener into each load image request instead of being injected
as a defaultRequestListener.

Refactored `InAppMessage` and `FirebaseInAppMessagingDisplayCallbacks`
assignment code for clarity.

Internal tracking: b/321732964

Issue: #5644
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: inappmessaging type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants