fluttercommunity / fluttercommunity/chewie
ErrorBuilder causes UI freeze due to infinite error callbacks during network issues (ffurl_read 0xffffff92)
- Dominant language
- Dart
- Stars
- 2.1k
- Forks
- 1.1k
- Avg merge
- 6d 8h
- Merged PRs (30d)
- 6
Description
---
# Severe UI Freezing When `errorBuilder` is Triggered Repeatedly
## **Description**
The **`errorBuilder`** callback in **`ChewieController`** causes severe UI freezing when network connectivity issues trigger continuous error callbacks.
During poor network conditions, the underlying video player (FFmpeg) generates repeated **`ffurl_read returned 0xffffff92`** TCP errors. These errors invoke **`errorBuilder`** in a tight, infinite loop on the main thread, overwhelming the UI and freezing the application.
---
## **Root Cause**
1. Network connectivity becomes unstable during video playback
2. FFmpeg/video player emits continuous **`ffurl_read returned 0xffffff92`** errors
3. Each error synchronously triggers **`errorBuilder`**
4. The callback executes on the UI thread (logging, analytics, widget building, etc.)
5. With no **rate limiting/debouncing**, hundreds/thousands of error callbacks flood the UI thread
6. Application becomes completely frozen
---
## **Error Pattern**
```
Error: ffurl_read returned 0xffffff92
Error: ffurl_read returned 0xffffff92
Error: ffurl_read returned 0xffffff92
... (repeats continuously during network issues)
```
---
## **Reproduction Steps**
1. Create a `ChewieController` with an `errorBuilder` performing any operation (logging, analytics, widget building, etc.)
2. Start video playback with a network URL
3. Simulate unstable/poor network conditions
4. Observe continuous **`ffurl_read returned 0xffffff92`** errors in logs
5. UI freezes as the error callback is executed infinitely
---
## **Problematic Code Example**
```dart
ChewieController(
videoPlayerController: newController,
errorBuilder: (context, errorMessage) {
debugPrint('Error: $errorMessage'); // Called hundreds of times per second
analytics.track(
AnalyticsPayload(
key: AnalyticsKeys.errorFromVideoPlayer,
props: {...?widget.analyticsPayload, 'errorMessage': errorMessage},
),
); // Heavy operation repeated infinitely
return const SizedBox.shrink(); // Widget rebuild repeated infinitely
},
);
```
---
## **Expected Behavior**
* `errorBuilder` should **not** be called infinitely for the same error
* The callback should be **debounced/throttled** or only triggered once per error event
* Application UI should remain responsive even under poor network conditions
---
## **Proposed Solutions**
* Add **internal debouncing** to `errorBuilder` calls
* Allow developers to configure **max frequency** or **rate limiting** of error callbacks
* Provide an option to **emit only the latest error** rather than triggering for every repeated FFmpeg error
---
## **Environment**
* **Chewie version**: 1.11.3
* **Video Player version**: 2.9.5
* **Flutter version**: stable 3.27.4
* **Platform**: Android
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.