invertase / react-native-notifee

Moved to https://github.com/invertase/notifee
https://invertase.io/blog/open-sourcing-notifee
Other
466 stars 31 forks source link

1.5.0 largeIcon bug in production build #292

Closed mars-lan closed 3 years ago

mars-lan commented 3 years ago

There seems to a bug introduced in 1.5.0 that causes notifications to not show when android.largeIcon is set. The strangest thing is that this happens only in production build. Debug build shows notifications as expected. Here's the canonical app to reproduce it.

import React from 'react';
import { AppRegistry } from 'react-native';
import notifee from '@notifee/react-native';

notifee.createChannel({
  id: 'channel',
  name: 'channel',
});

function Test() {
  React.useEffect(() => {
    notifee.displayNotification({
      title: 'Title',
      body: 'Body',
      android: {
        channelId: 'channel',
        largeIcon: require('./image.png'),
      },
    });
  }, []);
  return null;
}

AppRegistry.registerComponent('Test', () => Test);

This seems to affect all Android versions. My suspicion is that there's something wrong with the production build of the library. Downgrading to 1.4.0 fixes the problem reliably.

mikehardy commented 3 years ago

I don't think there is a difference in how the library builds between development and production but I have certainly seen a difference in how assets are packed (or "shrunk" out) on Android in production. Not sure if you've seen this but I basically don't tweet ever and was shocked enough to note this gotcha, could apply: https://twitter.com/fastsquatch/status/1196475279688028160 (in 3 parts).

mars-lan commented 3 years ago

@mikehardy Wow TIL. I assume this only applies to "local images" (required in JS land)? I did try to use Android native drawables in largeIcon and the result was the same. Let's see if @helenaford can reproduce this from her end.

mikehardy commented 3 years ago

I believe it can apply to any resources that the shrinker can't tell you are using. I think I put in there (or it's in the related link) how to do diagnostics to see what exactly is included. Alternatively you can try just turning off resource shrinking in production builds temporarily (or verifying it's disabled) as a quick check to eliminate the possibility. If I see resource missing / not displayed in production but works in debug on Android now, this is my first hunch basically.

mars-lan commented 3 years ago

@mikehardy thanks for the info. I tried disabling the shrinker explicitly by setting shrinkResources false in my build.gradle. Also verified that the image was indeed packaged into the final apk (res/drawable-mdpi-v4/image.png). Yet still hitting the same bug only for 1.5.0.

mikehardy commented 3 years ago

Thank you very much for verifying - I'm quite surprised by that result but that's why we test vs assume. On the pile for triage it goes :-)

helenaford commented 3 years ago

Fix pushed up in release v1.6.0. There was a problem with the license manager in v1.5.0 that we resolved here.

mikehardy commented 3 years ago

which was my error originally - typically I work on fully open products and I'm not used to there being other differences (like licensing) between debug and prod so I was way off on that one. Thanks for helping troubleshoot this @mars-lan

mars-lan commented 3 years ago

Thanks for the quick fix, @mikehardy & @helenaford . Can confirm that the issue has been fixed in 1.6.0.