Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing known flutter device connection issues #596

Closed
4 tasks done
josancamon19 opened this issue Aug 13, 2024 · 3 comments
Closed
4 tasks done

Fixing known flutter device connection issues #596

josancamon19 opened this issue Aug 13, 2024 · 3 comments
Assignees
Labels
flutter flutter work

Comments

@josancamon19
Copy link
Contributor

josancamon19 commented Aug 13, 2024

Describe the bug

  • 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)
  • When disconnected, switch off, go to paired device page, and appears Friend ()
  • 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 josancamon19 added the flutter flutter work label Aug 13, 2024
@josancamon19 josancamon19 self-assigned this Aug 13, 2024
@josancamon19
Copy link
Contributor Author

josancamon19 commented Aug 13, 2024

  • 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.

@francip
Copy link
Collaborator

francip commented Aug 13, 2024

  • 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)

@mdmohsin7 mdmohsin7 self-assigned this Aug 17, 2024
josancamon19 added a commit that referenced this issue Aug 18, 2024
Related to #596 

<!-- This is an auto-generated comment: release notes by OSS
Entelligence.AI -->
### Summary by Entelligence.AI

- Refactor: Updated the storage and retrieval mechanism of
`BTDeviceStruct` object in `SharedPreferencesUtil`. This change enhances
the application's ability to handle Bluetooth device information.
- Bug Fix: Improved Flutter connection handling and state management
across various pages. This includes checks before calling `setState` to
prevent errors and a more robust approach to showing SnackBar messages
when memory creation fails.
- New Feature: Added a connection listener on the found devices page,
improving the user experience by providing real-time updates about the
connection status.
<!-- end of auto-generated comment: release notes by OSS Entelligence.AI
-->
@mdmohsin7
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flutter flutter work
Projects
None yet
Development

No branches or pull requests

3 participants