Skip to content

Conversation

@wsxok
Copy link

@wsxok wsxok commented Feb 25, 2021

bytesToURI: function (data) {
        var blob = new Blob([data], {type: "image/jpeg"});
        /**
         * reason: The performance of 'URL.createObjectURL' is better than 'reader.readAsDataURL' ,
         * but 'URL.createObjectURL' will download picture in memory and it can not be cleared.
         * 'reader.readAsDataURL' will generate base64 code and auto GC.If we use 'URL.createObjectURL' here,
         * When the remote desktop is running long time and image chaning always,it will be out of memory.
         *
         */
        return  new Promise((resolve, reject) => {
            const reader  = new FileReader();
            reader.readAsDataURL(blob);
            reader.onload=function(){
                resolve(reader.result);
            };
        })
        // return URL.createObjectURL(blob);
    },

       return  new Promise((resolve, reject) => {
            const reader  = new FileReader();
            reader.readAsDataURL(blob);
            reader.onload=function(){
                resolve(reader.result);
            };
       })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant