Skip to content

Commit 8375824

Browse files
chasing crash on desktop/unix
1 parent d0c3d2e commit 8375824

File tree

6 files changed

+40
-11
lines changed

6 files changed

+40
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ internal_filesystem/SDLPointer_2
2222

2323
# config files etc:
2424
internal_filesystem/data
25+
26+
# private info
27+
draft_code/nostr_publish.py

internal_filesystem/boot_unix.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
import mpos.ui
88

9-
TFT_HOR_RES=640
10-
TFT_VER_RES=480
9+
#TFT_HOR_RES=640
10+
#TFT_VER_RES=480
11+
TFT_HOR_RES=320
12+
TFT_VER_RES=240
1113

1214
bus = lcd_bus.SDLBus(flags=0)
1315

internal_filesystem/lib/mpos/apps.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def execute_script(script_source, is_file, is_launcher, is_graphical):
6262
traceback.print_exception(type(e), e, tb)
6363

6464
# Run the script in a new thread:
65+
# TODO: check if the script exists here instead of launching a new thread?
6566
def execute_script_new_thread(scriptname, is_file, is_launcher, is_graphical):
6667
print(f"main.py: execute_script_new_thread({scriptname},{is_file},{is_launcher})")
6768
try:
@@ -70,8 +71,18 @@ def execute_script_new_thread(scriptname, is_file, is_launcher, is_graphical):
7071
# 16KB allows for 10 threads in the apps, but seems too tight for urequests on unix (desktop) targets
7172
# 32KB seems better for the camera, but it forced me to lower other app threads from 16 to 12KB
7273
#_thread.stack_size(24576) # causes camera issue...
73-
#_thread.stack_size(16384)
74-
_thread.stack_size(32*1024)
74+
75+
if "camtest" in scriptname:
76+
print("Starting camera with extra stack size!")
77+
stack=32*1024
78+
else:
79+
print("\n\n\nWHAAAAAAAAAAAAAAAAAA\n\n\n")
80+
#stack=16*1024 # somehow, on desktop, this causes a segfault... but the code isn't executed even!!!
81+
# [DEBUG 471155623] Connecting to wss://relay.damus.io
82+
# [DEBUG 471155623] Using SSL with no certificate verification
83+
stack=32*1024
84+
_thread.stack_size(stack)
85+
print(f"app.py set stack size to {stack}")
7586
_thread.start_new_thread(execute_script, (scriptname, is_file, is_launcher, is_graphical))
7687
except Exception as e:
7788
print("main.py: execute_script_new_thread(): error starting new thread thread: ", e)
@@ -169,11 +180,11 @@ def auto_connect():
169180
try:
170181
stat = uos.stat(custom_auto_connect)
171182
execute_script_new_thread(custom_auto_connect, True, False, False)
172-
except OSError:
183+
except Exception as e:
173184
try:
174-
print(f"Couldn't execute {custom_auto_connect}, trying {builtin_auto_connect}...")
185+
print(f"Couldn't execute {custom_auto_connect} because exception {e}, trying {builtin_auto_connect}...")
175186
stat = uos.stat(builtin_auto_connect)
176187
execute_script_new_thread(builtin_auto_connect, True, False, False)
177-
except OSError:
178-
print("Couldn't execute {builtin_auto_connect}, continuing...")
188+
except Exception as e:
189+
print("Couldn't execute {builtin_auto_connect} because exception {e}, continuing...")
179190

internal_filesystem/lib/threading.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def start(self):
1515
# 16KB still too much
1616
# _thread.stack_size(32*1024)
1717
#_thread.stack_size(10*1024) # might not be enough
18+
#stacksize = 12*1024
19+
# small stack sizes 8KB gives segfault directly
1820
stacksize = 12*1024
1921
print(f"starting thread with stacksize {stacksize}")
2022
_thread.stack_size(stacksize)

internal_filesystem/lib/websocket_nostr_receive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def printevents():
8282
# 24KB is fine
8383
# somehow, if I run this in a thread, I get: can't create thread" at File "/lib/nostr/relay_manager.py", line 48, in open_connections
8484
# tried stack sizes from 18KB up to 32KB
85-
_thread.stack_size(16*1024)
86-
_thread.start_new_thread(printevents, ())
87-
#printevents()
85+
#_thread.stack_size(16*1024)
86+
#_thread.start_new_thread(printevents, ())
87+
printevents()
8888

8989

9090
#import gc

internal_filesystem/main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414

1515
from mpos import apps
1616
apps.execute_script("builtin/system/button.py", True, False, False) # Install button handler through IRQ
17+
18+
import sys
19+
if sys.platform == "esp32":
20+
apps.auto_connect()
21+
else:
22+
pass
23+
#import _thread
24+
#import time
25+
26+
#_thread.stack_size(32*1024)
27+
#time.sleep(1)
1728
apps.auto_connect()
1829
apps.restart_launcher()
1930

0 commit comments

Comments
 (0)