{"record":{"id":"dc99dd7f57d1ae2b","repo":"BabylonJS/Babylon.js","slug":"updatewrappedwebgltexture-is-not-supported-use-up","errorCode":null,"errorMessage":"updateWrappedWebGLTexture is not supported, use updateWrappedNativeTexture instead.","messagePattern":"updateWrappedWebGLTexture is not supported, use updateWrappedNativeTexture instead\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/nativeEngine.pure.ts","lineNumber":44,"sourceCode":"     */\r\n    public constructor(options: NativeEngineOptions = {}) {\r\n        super(null, false, undefined, options.adaptToDeviceRatio);\r\n\r\n        this._initializeNativeEngine(options.adaptToDeviceRatio ?? false);\r\n    }\r\n\r\n    /**\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","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/nativeEngine.pure.ts#L26-L62","documentation":"NativeEngine cannot update a texture wrapped from WebGL handles because no WebGL texture exists in the native runtime. updateWrappedWebGLTexture() is intentionally stubbed to throw; the native counterpart is updateWrappedNativeTexture().","triggerScenarios":"Calling engine.updateWrappedWebGLTexture(texture) on a NativeEngine, typically from shared code that refreshes a wrapped texture's contents after context restore or dynamic update.","commonSituations":"Cross-platform code (web + Babylon Native) hitting the WebGL refresh path on native builds; context-restore recovery logic that has no meaning on native.","solutions":["Use updateWrappedNativeTexture() when running on NativeEngine.","Guard the call behind a platform check (wrapNativeTexture presence) and call the matching native API.","Skip the update entirely on native if the underlying native texture handle is unchanged."],"exampleFix":"// before\nengine.updateWrappedWebGLTexture(internalTex);\n// after\nif ((engine as any).updateWrappedNativeTexture) {\n  (engine as any).updateWrappedNativeTexture(internalTex);\n} else {\n  engine.updateWrappedWebGLTexture(internalTex);\n}","handlingStrategy":"type-guard","validationCode":"if (\"updateWrappedNativeTexture\" in engine) {\n  (engine as any).updateWrappedNativeTexture(tex);\n} else {\n  engine.updateWrappedWebGLTexture(tex);\n}","typeGuard":"function supportsNativeWrap(e) {\n  return \"updateWrappedNativeTexture\" in e;\n}","tryCatchPattern":"try {\n  engine.updateWrappedWebGLTexture(tex);\n} catch (e) {\n  if (/updateWrappedNativeTexture/.test(e.message)) {\n    (engine as any).updateWrappedNativeTexture(tex);\n  }\n}","preventionTips":["Pair wrap/update calls with their platform-correct variants.","Add a compile-time abstraction (interface with both methods) so TS flags misuse.","Run cross-platform smoke tests for texture lifecycle."],"tags":["babylon-native","textures","unsupported-api","platform"],"backgroundTag":"api-not-supported-on-platform","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}