omi icon indicating copy to clipboard operation
omi copied to clipboard

Fixing known flutter device connection issues

Open josancamon19 opened this issue 1 year ago • 2 comments

Describe the bug

  • [x] When connecting a device from found_devices, and after it auto navigates again to home page.
lutter: setState() called after dispose(): CapturePageState#64692(lifecycle state: defunct)
This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().

Visually it doesn't seem to be causing performance issues.

Steps to reproduce the behavior:

======== Exception caught by widgets library =======================================================
The following assertion was thrown while finalizing the widget tree:
CapturePageState.dispose failed to call super.dispose.

dispose() implementations must always call their superclass dispose() method, to ensure that all the resources used by the widget are fully released.
When the exception was thrown, this was the stack: 
#0      StatefulElement.unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:5701:7)
#1      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:5708:6)
#2      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:2077:13)
#3      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:2075:7)
#4      ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:5539:14)
#5      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:2073:13)
#6      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:2075:7)
#7      SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6755:14)
  • [x] When disconnected, switch off, go to paired device page, and appears Friend ()
  • [x] Go to found_devices, do not connect anything, go back home, enter found_devices again, no devices get displayed.
  • [ ] Disconnect device, connect device again, when entering home page again, the websocket disconnects en reconnects.
flutter: Subscribed to audioBytes stream from Friend Device
flutter: Websocket Opened
flutter: WebSocket connected successfully

**flutter: WebSocket connection closed: code ~ null, reason ~ null** 

flutter: Scheduling reconnection attempt 1 in 1 seconds
flutter: Attempting reconnection

flutter: Websocket Opening
flutter: Websocket Opened
flutter: WebSocket connected successfully

josancamon19 avatar Aug 13 '24 23:08 josancamon19

  • [ ] To this including bt_device object to have firmware version, and firmware details as part of the object, instead of separate preferences, ideally includes bootloader, fwver, etc.

josancamon19 avatar Aug 13 '24 23:08 josancamon19

  • [ ] To this including bt_device object to have firmware version, and firmware details as part of the object, instead of separate preferences, ideally includes bootloader, fwver, etc.

If possible, I'd add to this the model (DevKit1, DevKit1 SPI SD, DevKit2 if the device is running updated firmware that has that info) and capabilities as a form of flags or booleans (hasMemory, hasButton, hasCamera)

francip avatar Aug 13 '24 23:08 francip

The capture page dispose issue doesn't seem to happen anymore? And also the websocket disconnect and reconnect issue?

mdmohsin7 avatar Aug 31 '24 18:08 mdmohsin7