Forum Archive

Displaying to an external display stopped working.

samfrank

I have an app that I created a few years back to teach in my classroom. The app is using dual display with an HDMI cable.

To get dual display to work I used the code from this post. When iOS 13 came I had to tweak the code to get it to work:

# second_window.setHidden(False) <<-- changed to
second_windows.makeKeyAndVisible()

However, now with the newest update to iOS, every time the app tries to set the screen in the code for the second display, Pythonista completely crashes. I have tried the app store version and the beta version of Pythonista. So I am fairly sure that it is a change in the way iOS handles displaying to an external monitor. I checked the documentation but I still couldn't get it to work.

I don't know much about Objective-C so I am having a difficult time solving the issue. Any help or ideas would be appreciated.

cvp

@samfrank do you have some info about the crash reason?

samfrank

The app crashes Pythonista to the iOS home screen without producing an error. If I debug through the code the line that causes the crash is: second_window.setHidden(False). If I use makeKeyAndVisible() the crash still occurs. I wish I had more information to provide. Are there some hidden crash logs in Pythonista that I don't know about?

cvp

@samfrank there is a file named _objc_exception.txt in the root of Pythonista

cvp

You could also install the marvelous script of @dgelessus from here

samfrank

Thank you for your quick reply. I haven't tried the script yet, but the log contained the following:

This app was terminated due to an Objective-C exception.

threading violation: expected the main thread
cvp

@samfrank ok, you have to put

@on_main_thread  

just before the def calling the objectivec stuff. Could you post your code?

cvp

@cvp said:

Could you post your code?

Only if you need more help

samfrank

@cvp Thank you so much. It works perfectly! I learned a lot total about the Objective-C side of Pythonista, today.

I put the decorator @objc_util.on_main_thread on the function calling all of the second display code and now the app is running just like it used to before the iOS 13 updates.

Thanks again!