{"record":{"id":"0543bede555fdf98","repo":"BabylonJS/Babylon.js","slug":"uploadarraybufferviewtotexture-not-implemented","errorCode":null,"errorMessage":"_uploadArrayBufferViewToTexture not implemented.","messagePattern":"_uploadArrayBufferViewToTexture not implemented\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/nativeEngine.pure.ts","lineNumber":51,"sourceCode":"    /**\r\n     * @internal\r\n     */\r\n    public override wrapWebGLTexture(): InternalTexture {\r\n        throw new Error(\"wrapWebGLTexture is not supported, use wrapNativeTexture instead.\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     */\r\n    public override updateWrappedWebGLTexture(): void {\r\n        throw new Error(\"updateWrappedWebGLTexture is not supported, use updateWrappedNativeTexture instead.\");\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     */\r\n    public override _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, _faceIndex: number = 0, _lod: number = 0) {\r\n        throw new Error(\"_uploadArrayBufferViewToTexture not implemented.\");\r\n    }\r\n}\r\n\r\n/**\r\n * @internal\r\n * Augments the NativeEngine type to include ThinNativeEngine methods and preventing dupplicate TS errors\r\n */\r\nexport interface NativeEngine extends Omit<ThinNativeEngine, keyof Engine> {}\r\n\r\n/**\r\n * @internal\r\n * Applies the functionality of one or more base constructors to a derived constructor.\r\n */\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for nativeEngine.\r\n * Safe to call multiple times; only the first call has an effect.\r","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/nativeEngine.pure.ts#L33-L69","documentation":"NativeEngine's _uploadImageToTexture throws with the (mislabeled) message \"_uploadArrayBufferViewToTexture not implemented.\" This is a deliberately unimplemented override: HTMLImageElement-based upload is not supported in the native runtime, where images must be handled through native APIs.","triggerScenarios":"Calling engine._uploadImageToTexture(texture, htmlImage, faceIndex, lod) on NativeEngine — e.g. via texture.updateURL / loadFromImage paths that assume a browser DOM image.","commonSituations":"Porting web code to Babylon Native and using DOM Image uploads; react-native code passing an HTMLImageElement (which the native runtime never produces).","solutions":["On native, load textures via native image APIs (e.g. ThinNativeEngine's ArrayBuffer/binary upload paths such as _uploadArrayBufferViewToTexture once implemented, or load from file/URL handled natively).","Convert images to raw bytes (ArrayBuffer) before upload instead of HTMLImageElement.","Guard image-upload code paths behind a DOM-environment check when sharing code."],"exampleFix":"// before\nengine._uploadImageToTexture(texture, htmlImage, face, lod);\n// after\nif (typeof HTMLImageElement !== \"undefined\" && image instanceof HTMLImageElement && isNativeEngine(engine)) {\n  throwOrConvertToBytes(image); // use native loader instead\n} else {\n  engine._uploadImageToTexture(texture, image, face, lod);\n}","handlingStrategy":"validation","validationCode":"if (typeof HTMLImageElement === \"undefined\" || isNativeEngine(engine)) {\n  // load via native loader / ArrayBuffer path instead\n}","typeGuard":"function canUploadDomImage(engine, image) {\n  return typeof HTMLImageElement !== \"undefined\" && image instanceof HTMLImageElement && !(\"wrapNativeTexture\" in engine);\n}","tryCatchPattern":"try {\n  engine._uploadImageToTexture(texture, image, face, lod);\n} catch (e) {\n  if (/not implemented/.test(e.message)) {\n    loadTextureViaNativePath(texture, imageBytes);\n  }\n}","preventionTips":["On native, always load textures through native image/URL loaders, not DOM images.","Convert images to ArrayBuffer for portable upload code.","Feature-detect DOM APIs before using image-upload paths."],"tags":["babylon-native","textures","unsupported-api","image-upload"],"backgroundTag":"api-not-supported-on-platform","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}