Giter Site home page Giter Site logo

Comments (8)

tao-qian avatar tao-qian commented on June 14, 2024 2

Verified on our end that image compression is now happening consistently! Thanks!

from stream-chat-react-native.

khushal87 avatar khushal87 commented on June 14, 2024

Hey @tao-qian, thanks for bringing up this issue with us. So you mean this issue only happens when offline support is enabled by you?

from stream-chat-react-native.

tao-qian avatar tao-qian commented on June 14, 2024

Hey @tao-qian, thanks for bringing up this issue with us. So you mean this issue only happens when offline support is enabled by you?

I haven't actually tested this without offline support, and I just assumed that the behavior there would be different. IIUC, without offline support, the image will be in an "uploading" state with a spinner on top, once they are added to the input box, and the "Send" button won't actually be enabled, until the upload finishes. I assumed the "uploading" state would allow the compression to finish properly.

Whereas when offline support is enabled, the send button can be pressed right away as soon as the image is added. And based on my observation, if it is pressed without waiting for ~ 5 seconds, then the image that's sent won't be compressed.

from stream-chat-react-native.

khushal87 avatar khushal87 commented on June 14, 2024

Thanks for pointing this out to us @tao-qian. This indeed looks like an issue. We will investigate and get this fixed and reach out to you soon. Thanks 😄

from stream-chat-react-native.

tao-qian avatar tao-qian commented on June 14, 2024

Thanks for pointing this out to us @tao-qian. This indeed looks like an issue. We will investigate and get this fixed and reach out to you soon. Thanks 😄

Thanks! Please keep us posted!

from stream-chat-react-native.

khushal87 avatar khushal87 commented on June 14, 2024

Hey @tao-qian, we have fixed it in #2331 and its merged as well. Please wait for the next release and this should fix your issue. Do let us know if it doesn't work. Thanks 😄

from stream-chat-react-native.

tao-qian avatar tao-qian commented on June 14, 2024

Hey @tao-qian, we have fixed it in #2331 and its merged as well. Please wait for the next release and this should fix your issue. Do let us know if it doesn't work. Thanks 😄

Thanks a lot for the quick turnaround! We will keep an eye out for the next release then try this out!

from stream-chat-react-native.

tao-qian avatar tao-qian commented on June 14, 2024

We are seeing additional cases of images not getting compressed :(

This time it is harder to reproduce and I haven't figure out the consistent repro steps yet. However, it typically happens after I sent a few images in a row (e.g. 10). The worrying part for this bug is that once it happens, the subsequent images also won't be compressed. However, this sometimes would reset, after a text message is sent.

Here are two image messages for the same image. One of them is compressed as expected, but the other one is not:

Note that the two images practically look the same, but if you download them, one of them would be 400 kb while the other would be 1.5 mb.

We are overriding the compressImage handler to use the latest version of the ImageResizer library (@bam.tech/react-native-image-resizer). Here is our logic:

 compressImage: async ({
      compressImageQuality = 1,
      height,
      uri,
      width,
    }) => {
      try {
        const { uri: compressedUri } = await ImageResizer.createResizedImage(
          uri,
          width,
          height,
          'JPEG',
          Math.min(Math.max(0, compressImageQuality), 1) * 100,
          0,
          undefined,
          false,
          { mode: 'cover' },
        );
        return compressedUri;
      } catch (error) {
        Sentry.captureException(error);
        return uri;
      }
    },

We have confirmed that the input and output for compressImage didn't change when this bug happens:

  • input parameters height, width, compressImageQuality, uri are all correct
  • the uri in the output has the correct size (e.g. 400KB), when I checked it with react-native-fs

We are still trying to figure out more consistent repro steps, but just want to share the findings so far in case the behavior rings a bell. Thanks!

from stream-chat-react-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.