flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.5k stars 449 forks source link

Able to crash android app with client storage #4267

Open syleishere opened 3 weeks ago

syleishere commented 3 weeks ago

Duplicate Check

Describe the bug

This bug did not occur in flet 0.24.x versions, just in recent 0.25.x versions. Once I located this bug today, I tried removing try/except clause and there was information about error oddly enough. Still in it's current form it crashes all android apps with generic message.

Code sample

Code ```python import flet as ft async def main(page: ft.Page): # crash android app start try: token = None await page.client_storage.set_async("crystaltunes.token", token) except Exception as e: print(f"Exception occurred {e}") # crash android app end page.add(ft.Text("Hello, Flet!")) ft.app(main)```

To reproduce

flet create someapp cd someapp (toss code into main.py) flet build apk

Expected behavior

Exception should have shown at least something. What is strange is that code was working for long time up to 0.24.x.

Screenshots / Videos

No response

Operating System

Linux

Operating system details

Android

Flet version

Name: flet Version: 0.25.0.dev3614

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

Need a more fine tuned approached to not let this error pass into dart code to crash the app as debugging this was a nightmare.

Logs

Logs ```console 10-30 17:06:50.373 24940 24962 E flutter : [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'String' in type cast 10-30 17:06:50.373 24940 24962 E flutter : #0 new LinkedHashMap.from. (dart:collection/linked_hash_map.dart:187) 10-30 17:06:50.373 24940 24962 E flutter : #1 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633) 10-30 17:06:50.373 24940 24962 E flutter : #2 new LinkedHashMap.from (dart:collection/linked_hash_map.dart:186) 10-30 17:06:50.373 24940 24962 E flutter : #3 new InvokeMethodPayload.fromJson (package:flet/src/protocol/invoke_method_payload.dart:19) 10-30 17:06:50.373 24940 24962 E flutter : #4 FletServer._onMessage (package:flet/src/flet_server.dart:238) 10-30 17:06:50.373 24940 24962 E flutter : #5 FletTcpSocketServerProtocol._onMessage (package:flet/src/flet_server_protocol_tcp_socket.dart:125) 10-30 17:06:50.373 24940 24962 E flutter : #6 FletTcpSocketServerProtocol.connect. (package:flet/src/flet_server_protocol_tcp_socket.dart:94) 10-30 17:06:50.373 24940 24962 E flutter : #7 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594) 10-30 17:06:50.373 24940 24962 E flutter : #8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:365) 10-30 17:06:50.373 24940 24962 E flutter : #9 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297) 10-30 17:06:50.373 24940 24962 E flutter : #10 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784) 10-30 17:06:50.373 24940 24962 E flutter : #11 _StreamController._add (dart:async/stream_controller.dart:658) 10-30 17:06:50.373 24940 24962 E flutter : #12 _StreamController.add (dart:async/stream_controller.dart:606) 10-30 17:06:50.373 24940 24962 E flutter : #13 _Socket._onData (dart:io-patch/socket_patch.dart:2455) 10-30 17:06:50.373 24940 24962 E flutter : #14 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594) 10-30 17:06:50.373 24940 24962 E flutter : #15 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:365) 10-30 17:06:50.373 24940 24962 E flutter : #16 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297) 10-30 17:06:50.373 24940 24962 E flutter : #17 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784) 10-30 17:06:50.373 24940 24962 E flutter : #18 _StreamController._add (dart:async/stream_controller.dart:658) 10-30 17:06:50.373 24940 24962 E flutter : #19 _StreamController.add (dart:async/stream_controller.dart:606) 10-30 17:06:50.373 24940 24962 E flutter : #20 new _RawSocket. (dart:io-patch/socket_patch.dart:1942) 10-30 17:06:50.373 24940 24962 E flutter : #21 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1385) 10-30 17:06:50.373 24940 24962 E flutter : #22 _microtaskLoop (dart:async/schedule_microtask.dart:40) 10-30 17:06:50.373 24940 24962 E flutter : #23 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49) 10-30 17:06:50.373 24940 24962 E flutter : ```

Additional details

No response

syleishere commented 3 weeks ago

Very slimmed down version of what I had, essentially token was set to None, till there was a successful login, then it got set.