flet-dev / serious-python

Python runtime for Flutter apps
Apache License 2.0
212 stars 22 forks source link

runProgram causes android crash #57

Closed khaven closed 10 months ago

khaven commented 10 months ago

Hi, I'm trying to create a python script file and run the file using the SeriousPython.runProgram function but it causing the android to crash. Here's my code:

File file = await File(p.join((await getApplicationDocumentsDirectory()).path, 'myfile.py')).create(recursive: true);

file.writeAsStringSync('print("hello world")', flush: true);

Directory.current = p.dirname(file.path);

print(file.path);

String? out = await SeriousPython.runProgram(file.path, environmentVariables: {"a": "1", "b": "2"},  sync: true);

print(out);

Here's the console output: Capture

FeodorFitsner commented 10 months ago

Oh, it's x86_64 architecture. What kind of device is that?

FeodorFitsner commented 10 months ago

I have no idea, why it's crashing with null pointer, but it happens on x86_64 architecture. I don't know if it's on specific or all devices, but that was the reason we disabled x86_64 arch for Flet app in Google Play.

I guess this is relevant CPython code: https://github.com/python/cpython/blob/3.11/Python/import.c#L1996 https://github.com/python/cpython/blob/3.11/Objects/listobject.c#L155

How to debug that? I don't have much C experience 🥹

FeodorFitsner commented 10 months ago

It works on x86_64 Android simulator though: https://ci.appveyor.com/project/flet-dev/serious-python/build/job/o8j1f3wm73qdjb56#L373

khaven commented 10 months ago

I don't know what I did wrong. But after creating a new project, the code is working fine on the same Android emulator. I wish it returned "hello world" instead of "null" though. I was testing the code on the flask example before. Thank you for your help :)

FeodorFitsner commented 10 months ago

OK, thanks for the update. I don't like that sporadic error though. I'm working right now on catching output. It's going to be for Android first.

khaven commented 10 months ago

I'm so excited to hear that! Thanks again. I'm closing this issue.