Get image src from ImageBitmap using child.material.map.image

I am trying to get image from ImageBitmap of a loaded model but since ImageBitmap does not have src, I am using canvas.toDataURL().

small size images are getting painted fine without any problem but a 4mb texture is not loading completely.

Since child.material.map does not have src, I am not able to use image.onload.

const c = document.createElement('canvas');
                c.width = child.material.map.image.width;
                c.height = child.material.map.image.height;
                const ctx = c.getContext('2d');

                ctx.drawImage(child.material.map.image, 0, 0, child.material.map.image.width, child.material.map.image.height, 0, 0, c.width, c.height);
                console.log(c.toDataURL());

I skipped some code for simplicity.