Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bytesToURI:URL.createObjectURL issue #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

bytesToURI:URL.createObjectURL issue #2

wants to merge 1 commit into from

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