Saturday, February 22, 2025
spot_img

Android 14 for some cause the drawImage operate is lacking in CanvasRenderingContext2D – Cocos Creator


Good day, I take advantage of JS and canvas to arrange a picture for Sprite

When testing the appliance on a tool utilizing Android 14, an issue arose with the dearth of the drawImage operate in CanvasRenderingContext2D

Code for figuring out the issue

let CoverCanvas = doc.createElement(“canvas”);

let Cover_ctx = CoverCanvas.getContext(“second”);

console.log(‘Direct Cover_ctx:’, Cover_ctx);

console.log(‘Direct Cover_ctx drawImage exists?’, typeof Cover_ctx.drawImage === “operate”);

console.log(‘Cover_ctx constructor:’, Cover_ctx.constructor.title);
console.log(‘Cover_ctx prototype:’, Object.getPrototypeOf(Cover_ctx));
console.log(‘Cover_ctx keys:’, Object.keys(Cover_ctx));

if (typeof Cover_ctx.drawImage !== “operate”) {
console.error(“Error: Cover_ctx.drawImage will not be a operate!”, Cover_ctx);

                }

if (!Cover_ctx || !(Cover_ctx instanceof CanvasRenderingContext2D)) {
console.log(‘Error: Cover_ctx will not be a CanvasRenderingContext2D!’, Cover_ctx);
} else {console.log(‘Cover_ctx is a CanvasRenderingContext2D!’, Cover_ctx);}

Logs obtained in Android Studio

D 18:32:07 [DEBUG]: JS: Direct Cover_ctx: [object Object]

D 18:32:07 [DEBUG]: JS: Direct Cover_ctx drawImage exists? false

D 18:32:07 [DEBUG]: JS: Cover_ctx constructor: CanvasRenderingContext2D

D 18:32:07 [DEBUG]: JS: Cover_ctx prototype: [object Object]

D 18:32:07 [DEBUG]: JS: Cover_ctx keys: _nativeObj,_attris,_canvas

E 18:32:07 [ERROR]: JS: Error: Cover_ctx.drawImage will not be a operate! [object Object]

D 18:32:07 [DEBUG]: JS: Cover_ctx is a CanvasRenderingContext2D! [object Object]

I’m utilizing Cocos Creator 3.8.4, Android Studio Koala 2024.1.1 API 33

There is no such thing as a such downside within the browser. Inform me the place to search for the reason for the issue. Thanks prematurely on your assist.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles