6***@qq.com
6***@qq.com
  • 发布:2020-11-06 14:58
  • 更新:2020-11-09 15:49
  • 阅读:1943

【报Bug】很急,期望快点解决: 多个uni.getImageInfo 并发执行,返回的 path 大概率会有重复

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 10.15.6

HBuilderX类型: Alpha

HBuilderX版本号: 2.9.7

手机系统: Android

手机系统版本号: Android 11

手机厂商: 小米

手机机型: 小米MIX3

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<template>  
    <view class="content">  
        <image class="logo" src="/static/logo.png"></image>  
        <view class="text-area">  
            <button type="default" @click="onDrowImg">点击获取图像信息</button>  
        </view>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                title: 'Hello'  
            }  
        },  
        onLoad() {  

        },  
        methods: {  
            onDrowImg() {  
                let promise1 = new Promise((resolve, reject) => {  
                    let avatar = 'http://shopmakeup-static.zonejoin.cn/2019/3/17/102215761978855342.png'  
                    /* 获得要在画布上绘制的图片 => 头像 */  
                    uni.getImageInfo({  
                        src: avatar,  
                        success: res => resolve(res)  
                    })  
                });  

                let promise2 = new Promise((resolve, reject) => {  
                    /* 获得要在画布上绘制的图片 => 背景图 */  
                    let src =  'https://shopnaly-s.zonejoin.cn/2020/3/20/14324957502702095.png'  
                    uni.getImageInfo({  
                        src: src,  
                        success: res =>resolve(res)  
                    });  
                });  
                let promise3 = new Promise((resolve, reject) => {  
                    /* 获得要在画布上绘制的logo*/  
                    uni.getImageInfo({  
                        src: 'https://shopnaly-s.zonejoin.cn/2020/1/3/12.png',  
                        success: res => resolve(res),  
                        fail: error => reject(error)  
                    });  
                });  
                let promise4 = new Promise((resolve, reject) => {  
                    /* 获得要在画布上绘制的logo*/  
                    uni.getImageInfo({  
                        src: 'http://img.huangxiaoyong.com/8c3a41ac9c08118898944270d7d6087b.png',  
                        success: res => resolve(res),  
                        fail: error => reject(error)  
                    });  
                });  
                let promise5 = new Promise((resolve, reject) => {  
                    /* 获得要在画布上绘制的logo*/  
                    uni.getImageInfo({  
                        src: 'http://img.huangxiaoyong.com/2e2c03117c2924d170fe8e057f4dbbc7.png',  
                        success: res => resolve(res),  
                        fail: error => reject(error)  
                    });  
                });  

                Promise.all(  
                    [promise1, promise2, promise3, promise4,promise5]  
                ).then(res => {  
                    console.log(res)  
                }).catch(error => {  

                })  
            }  
        }  
    }  
</script>  

<style>  
    .content {  
        display: flex;  
        flex-direction: column;  
        align-items: center;  
        justify-content: center;  
    }  

    .logo {  
        height: 200rpx;  
        width: 200rpx;  
        margin-top: 200rpx;  
        margin-left: auto;  
        margin-right: auto;  
        margin-bottom: 50rpx;  
    }  

    .text-area {  
        display: flex;  
        justify-content: center;  
    }  

    .title {  
        font-size: 36rpx;  
        color: #8f8f94;  
    }  
</style>  

操作步骤:

多次点击,会发现返回的path 有大概率重复

预期结果:

希望获取的path值想对应

实际结果:

实际大概率重复

bug描述:

多个并发请求的uni.getImageInfo ,返回的path 大概率重复
如下图返回的结果, 1604645769068 这个重复出现了3次,在做分享海报时会用到。
经过测试。 正式版 2.9.7 跟 alpha 版 2.9.7 都存在该问题

[{  
    "path": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp_1604645765773/download/1604645769046",  
    "width": 150,  
    "height": 150,  
    "orientation": "up",  
    "type": "png",  
    "errMsg": "getImageInfo:ok"  
}, {  
    "path": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp_1604645765773/download/1604645769067",  
    "width": 750,  
    "height": 1334,  
    "orientation": "up",  
    "type": "png",  
    "errMsg": "getImageInfo:ok"  
}, {  
    "path": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp_1604645765773/download/1604645769068",  
    "width": 374,  
    "height": 117,  
    "orientation": "up",  
    "type": "png",  
    "errMsg": "getImageInfo:ok"  
}, {  
    "path": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp_1604645765773/download/1604645769068",  
    "width": 750,  
    "height": 1334,  
    "orientation": "up",  
    "type": "png",  
    "errMsg": "getImageInfo:ok"  
}, {  
    "path": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp_1604645765773/download/1604645769068",  
    "width": 374,  
    "height": 117,  
    "orientation": "up",  
    "type": "png",  
    "errMsg": "getImageInfo:ok"  
}]  
2020-11-06 14:58 负责人:DCloud_Android_zl 分享
已邀请:
DCloud_Android_zl

DCloud_Android_zl

问题已经确定,将会再下版更新,暂时可以通过挨个获取来解决当前问题,不要同时请求所有的。

  • 6***@qq.com (作者)

    2.9.8版本在11月10号更新,未解决该问题,下个版本会更新吗?

    2020-11-11 09:19

  • DCloud_Android_zl

    回复 6***@qq.com: 下个版本会更新

    2020-11-11 12:21

6***@qq.com

6***@qq.com (作者)

并发在5个以上出现的概率很大

6***@qq.com

6***@qq.com (作者)

有人解决一下吗?做分享海报时需要用到,上个版本都没问题,更新后出问题了

该问题目前已经被锁定, 无法添加新回复