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

Pythonista crash during start launch_stash.py #496

Open
mrkeuz opened this issue May 8, 2023 · 9 comments
Open

Pythonista crash during start launch_stash.py #496

mrkeuz opened this issue May 8, 2023 · 9 comments

Comments

@mrkeuz
Copy link

mrkeuz commented May 8, 2023

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 mrkeuz changed the title Pythonista crash during stash start Pythonista crash during start launch_stash.py May 8, 2023
@cclauss
Copy link
Collaborator

cclauss commented May 8, 2023

Try this command instead... #462 (comment)

@cclauss cclauss closed this as completed May 8, 2023
@mrkeuz
Copy link
Author

mrkeuz commented May 8, 2023

Tried, same result.

@lanceDee
Copy link

lanceDee commented May 11, 2023

@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...

@YoYulyvW
Copy link

YoYulyvW commented May 15, 2023

有用 (it works)

@RimePendragon
Copy link

@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

@cclauss cclauss reopened this May 19, 2023
@lanceDee
Copy link

lanceDee commented May 23, 2023

@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.

@mrkeuz
Copy link
Author

mrkeuz commented May 23, 2023

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.

@felciano
Copy link

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?

@mrlucmorin
Copy link

Additional notes.

  • Found workaround

Did you create a pull request?

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

7 participants