releaseGpuTexture method
(Android only) Release the native GPU texture.
Implementation
Future<void> releaseGpuTexture({bool graceful = false}) async {
final textureId = _gpuTextureId;
if (textureId == null) {
return;
}
if (graceful && _gpuSurfaceHandle != null && _gpuSurfaceHandle != 0) {
// Ask the render stream to drop the current GPU surface before we tear
// down the platform texture to avoid transient BufferQueue/Vulkan errors.
_gpuSurfaceHandle = 0;
notifyListeners();
await Future<void>.delayed(const Duration(milliseconds: 16));
}
_gpuTextureId = null;
_gpuSurfaceHandle = null;
// Do not clear _gpuBackend so _onResume can know what backend to restore.
notifyListeners();
try {
await _channel.invokeMethod('releaseTexture', {'textureId': textureId});
} catch (_) {
// Best effort; local controller state is already detached.
}
}