{"record":{"id":"d904549dc61c16d4","repo":"koral--/android-gif-drawable","slug":"changing-surfacetexturelistener-is-not-supported","errorCode":null,"errorMessage":"Changing SurfaceTextureListener is not supported","messagePattern":"Changing SurfaceTextureListener is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextureView.java","lineNumber":114,"sourceCode":"\t\t\tviewAttributes = new GifViewUtils.GifViewAttributes();\n\t\t}\n\t\tif (!isInEditMode()) {\n\t\t\tmRenderThread = new RenderThread(this);\n\t\t\tif (mInputSource != null) {\n\t\t\t\tmRenderThread.start();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Always throws {@link UnsupportedOperationException}. Changing {@link SurfaceTextureListener}\n\t * is not supported.\n\t *\n\t * @param listener ignored\n\t */\n\t@Override\n\tpublic void setSurfaceTextureListener(SurfaceTextureListener listener) {\n\t\tthrow new UnsupportedOperationException(\"Changing SurfaceTextureListener is not supported\");\n\t}\n\n\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 */","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/koral--/android-gif-drawable/blob/26ff795f78b7fe8bbaf375a947b2bda95fc58e3d/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifTextureView.java#L96-L132","documentation":"GifTextureView overrides setSurfaceTextureListener to deliberately forbid changing the listener, because the view manages its own SurfaceTextureListener internally for GIF rendering. Any call throws UnsupportedOperationException('Changing SurfaceTextureListener is not supported').","triggerScenarios":"Calling gifTextureView.setSurfaceTextureListener(myListener) directly, or indirectly via framework code that sets listeners on TextureView subclasses.","commonSituations":"Treating GifTextureView as a drop-in TextureView and copying TextureView setup code; UI frameworks or abstractions that programmatically assign surface listeners.","solutions":["Remove the setSurfaceTextureListener call — GifTextureView handles its own rendering.","Don't use GifTextureView if you need a custom SurfaceTextureListener; use a plain TextureView plus your own GIF decoding.","Observe rendering via GifTextureView's other APIs (e.g. the underlying GifDrawable callbacks) instead of the listener."],"exampleFix":"// before\ngifTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {...});\n// after\n// removed: GifTextureView manages its own SurfaceTextureListener internally","handlingStrategy":"type-guard","validationCode":"if (!(view instanceof GifTextureView)) { view.setSurfaceTextureListener(listener); }","typeGuard":"boolean supportsListenerChange(View v) { return !(v instanceof GifTextureView); }","tryCatchPattern":"try { view.setSurfaceTextureListener(listener); } catch (UnsupportedOperationException e) { /* GifTextureView: use its own APIs instead */ }","preventionTips":["Do not treat GifTextureView as a fully configurable TextureView","Skip listener setup code paths for GifTextureView instances","Use GifDrawable callbacks to observe rendering"],"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"}