stash icon indicating copy to clipboard operation
stash copied to clipboard

Pythonista crash during start launch_stash.py

Open mrkeuz opened this issue 2 years ago • 9 comments

Steps for reproduce

  • Install via import requests as r; exec(r.get('https://bit.ly/get-stash').content)
  • Launch launch_stash.py from

Result

In This phone folder appear _objc_exception.txt with text:

The app was terminated due to an Objective-C exception. Details below:

2023-05-08 08:28:08.740591
Modifications to the layout engine must not be performed from 
a background thread after it has been accessed from the main thread.

Env:

  • Pythonista v 3.4 (340012)
  • Stash 0.7.5 (latest master, same on dev)
  • Ios 15.6.1

mrkeuz avatar May 08 '23 10:05 mrkeuz

Try this command instead... https://github.com/ywangd/stash/issues/462#issuecomment-1472858042

cclauss avatar May 08 '23 15:05 cclauss

Tried, same result.

mrkeuz avatar May 08 '23 15:05 mrkeuz

@mrkeuz @cclauss I ran into same problem...

However this issue could be workarounded following steps as below:

  1. Set breakpoint at the '_stash.launch(ns.command)' line at the bottom of the "launch_stash.py" file
  2. Run the launch script with Debug mode
  3. When it reaches the breakpoint, run with "single step" and the terminal window will show up

I have no idea how Debug mode made the difference...

lanceDee avatar May 11 '23 06:05 lanceDee

有用 (it works)

YoYulyvW avatar May 15 '23 20:05 YoYulyvW

@cclauss Why is this closed ? I have this problem and the suggested comment did not work. If I do the debug trick suggested by @lanceDee I see the console but then when I single step the terminal window does show up but in the next step the app crashes. File 19-05-2023, 11 01 28

RimePendragon avatar May 19 '23 09:05 RimePendragon

@cclauss Why is this closed ? I have this problem and the suggested comment did not work. If I do the debug trick suggested by @lanceDee I see the console but then when I single step the terminal window does show up but in the next step the app crashes. File 19-05-2023, 11 01 28

Yes, it does crash when you step over and do nothing with the console. But as long as the console is active, you should be able to run some shell command with it, and if you found the window hang, just press the "single step run” for another time. However, official fix for this issue is still needed, please try the trick cautiously.

lanceDee avatar May 23 '23 06:05 lanceDee

Additional notes.

  • Found workaround

    Edit launch_stash.py replace line 103 _stash.launch(ns.command) with:

    # Line 103 replace with:
    import ui
    
    @ui.in_background
    def launch(*args):
        _stash.launch(*args)
    launch(ns.command)
    

    source here

  • Similar crashes in scripts

    I also found crash on other Pythonista examples. I.e. altimeter example also crash (except without _objc_exception.txt)

    Somewhere in lines:

    ...
    main_q = NSOperationQueue.mainQueue()
    altimeter.startRelativeAltitudeUpdatesToQueue_withHandler_(main_q, handler_block)
    ...
    

    I found many discussions on omz forum i.e. this or this I.m. not IOS developer, so cannot summarize reports about main/background threads using in obj-c, but maybe omz topics about Pythonista 3.4/3.4 beta helps for someone.

mrkeuz avatar May 23 '23 07:05 mrkeuz

I just ran into this issue (Stash crashing as soon as you run launch_stash.py). I can confirm that the workaround solved the issue (thanks @mrkeuz). Seems like the source file should be updated?

felciano avatar Oct 19 '23 00:10 felciano

Additional notes.

  • Found workaround

Did you create a pull request?

mrlucmorin avatar Jun 18 '24 20:06 mrlucmorin