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

Able to crash android app with client storage #4267

Open
1 task done
syleishere opened this issue Oct 30, 2024 · 1 comment
Open
1 task done

Able to crash android app with client storage #4267

syleishere opened this issue Oct 30, 2024 · 1 comment

Comments

@syleishere
Copy link
Contributor

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

</details>


### 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

<details open><summary>Logs</summary>

```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.<anonymous closure> (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.<anonymous closure> (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.<anonymous closure> (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
Copy link
Contributor Author

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

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

No branches or pull requests

1 participant