open-im-sdk-reactnative icon indicating copy to clipboard operation
open-im-sdk-reactnative copied to clipboard

[BUG] Sending high-resolution images causes the app to crash

Open OrrinHatch opened this issue 1 year ago • 11 comments

OpenIM Server Version

3.8.0

Operating System and CPU Architecture

Linux (AMD)

Deployment Method

Docker Deployment

Bug Description and Steps to Reproduce

const selectImage = async () => {
    // 请求访问媒体库的权限
    const { granted } = await requestMediaLibraryPermissionsAsync();
    if (!granted) {
      Alert.alert('Permissions denied!');
      return;
    }
    // 打开图片库
    const resp = await launchImageLibraryAsync({
      mediaTypes: MediaTypeOptions.Images,
      allowsMultipleSelection: false,
      selectionLimit: 1,
      quality: 0.75, // 保持高质量,但后续我们会进行压缩
    });

    if (resp.canceled) {
      return;
    }
    if (resp.assets && resp.assets.length > 0) {
      let { uri } = resp.assets[0];

      if (uri) {
        if (uri.startsWith('file://')) {
          uri = uri.substring(7);
        }

        // 创建图片消息并发送
        const message = await OpenIMSDKRN.createImageMessageFromFullPath(uri, uuidv4());
        sendMessage({ message });
      }
    }
  };

Screenshots Link

No response

OrrinHatch avatar Sep 12 '24 08:09 OrrinHatch

quality can not set 1 or 0.9

OrrinHatch avatar Sep 12 '24 08:09 OrrinHatch

If you choose a high-resolution image, what might go wrong? Can you locate the specific function?

lgz5689 avatar Sep 12 '24 09:09 lgz5689

截屏2024-09-12 18 54 23

OrrinHatch avatar Sep 12 '24 10:09 OrrinHatch

When executing this line : const successMessage = await OpenIMSDKRN.sendMessage(options, uuidv4());

OrrinHatch avatar Sep 12 '24 10:09 OrrinHatch

这个问题解决了吗?

daxingyun avatar Sep 20 '24 08:09 daxingyun

我有个一样的问题,发送图片消息必然崩溃,反复测试过:与压缩,和图片大小应该是没有关系的。比如发送1M 以及压缩至100KB ,发送都会崩溃。 目前我的解决方案是通过OpenIMSDKRN.uploadFile先上传,再通过OpenIMSDKRN.sendMessage发送图片消息。但这个方案无法读取进度条。期待尽快解决!

daxingyun avatar Sep 20 '24 09:09 daxingyun

@OrrinHatch 谢谢。。

daxingyun avatar Sep 23 '24 07:09 daxingyun

@daxingyun 或者 在这个文件 https://github.com/openimsdk/open-im-sdk-reactnative/blob/main/android/src/main/java/com/openimsdkrn/SendMsgCallBack.java

OrrinHatch avatar Sep 23 '24 07:09 OrrinHatch

截屏2024-09-23 15 53 10

OrrinHatch avatar Sep 23 '24 07:09 OrrinHatch

@OrrinHatch 我的问题似乎已经解决了,我修改的代码:params.putMap("message", Arguments.makeNativeMap(message.toHashMap())); ,copy()是不存在的函数。谢谢。。。

daxingyun avatar Sep 23 '24 11:09 daxingyun