{"record":{"id":"dc71e689305d3fce","repo":"koral--/android-gif-drawable","slug":"changing-surfacetexture-is-not-supported","errorCode":null,"errorMessage":"Changing SurfaceTexture is not supported","messagePattern":"Changing SurfaceTexture is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextureView.java","lineNumber":135,"sourceCode":"\t/**\n\t * Always returns null since changing {@link SurfaceTextureListener} is not supported.\n\t *\n\t * @return always null\n\t */\n\t@Override\n\tpublic SurfaceTextureListener getSurfaceTextureListener() {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Always throws {@link UnsupportedOperationException}. Changing {@link SurfaceTexture} is not\n\t * supported.\n\t *\n\t * @param surfaceTexture ignored\n\t */\n\t@Override\n\tpublic void setSurfaceTexture(@NonNull SurfaceTexture surfaceTexture) {\n\t\tthrow new UnsupportedOperationException(\"Changing SurfaceTexture is not supported\");\n\t}\n\n\tprivate static InputSource findSource(final TypedArray textureViewAttributes) {\n\t\tfinal TypedValue value = new TypedValue();\n\t\tif (!textureViewAttributes.getValue(R.styleable.GifTextureView_gifSource, value)) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (value.resourceId != 0) {\n\t\t\tfinal String resourceTypeName = textureViewAttributes.getResources().getResourceTypeName(value.resourceId);\n\t\t\tif (GifViewUtils.SUPPORTED_RESOURCE_TYPE_NAMES.contains(resourceTypeName)) {\n\t\t\t\treturn new InputSource.ResourcesSource(textureViewAttributes.getResources(), value.resourceId);\n\t\t\t} else if (!\"string\".equals(resourceTypeName)) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"Expected string, drawable, mipmap or raw resource type. '\" + resourceTypeName\n\t\t\t\t\t\t\t\t+ \"' is not supported\");\n\t\t\t}\n\t\t}","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/koral--/android-gif-drawable/blob/26ff795f78b7fe8bbaf375a947b2bda95fc58e3d/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextureView.java#L117-L153","documentation":"GifTextureView overrides setSurfaceTexture to forbid replacing the SurfaceTexture it drives GIF decoding with. Any call throws UnsupportedOperationException('Changing SurfaceTexture is not supported'), since the texture lifecycle is owned by the view's rendering pipeline.","triggerScenarios":"Calling gifTextureView.setSurfaceTexture(surfaceTexture) directly, e.g. code that shares or reassigns SurfaceTextures across TextureViews.","commonSituations":"Reusing an existing SurfaceTexture from another view for performance; generic view-configuration code paths that call setSurfaceTexture on any TextureView.","solutions":["Remove the setSurfaceTexture call — let GifTextureView create and manage its own SurfaceTexture.","If SurfaceTexture reuse is required, use a plain TextureView instead of GifTextureView.","Interact with the GIF via GifDrawable/handle APIs rather than the texture."],"exampleFix":"// before\ngifTextureView.setSurfaceTexture(sharedSurfaceTexture);\n// after\n// removed: GifTextureView owns its SurfaceTexture; use a plain TextureView if you must share one","handlingStrategy":"type-guard","validationCode":"if (!(view instanceof GifTextureView)) { view.setSurfaceTexture(surfaceTexture); }","typeGuard":"boolean supportsSurfaceTextureChange(View v) { return !(v instanceof GifTextureView); }","tryCatchPattern":"try { view.setSurfaceTexture(surfaceTexture); } catch (UnsupportedOperationException e) { /* GifTextureView owns its SurfaceTexture */ }","preventionTips":["Let GifTextureView create its own SurfaceTexture","Use a plain TextureView when SurfaceTexture reuse is required","Avoid generic view-config code that sets textures on all TextureViews"],"tags":["android","unsupported-operation","textureview"],"backgroundTag":"unsupported-operation","analyzedSha":"26ff795f78b7fe8bbaf375a947b2bda95fc58e3d","analyzedAt":"2026-09-10T14:37:11.595Z","contentChangedAt":"2026-09-10T14:37:11.595Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}