Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Pythonista UI + SceneView + PhotoPicker keep crashing
-
Greetings,
Long time no see, I've been playing around with the new Pythonista 3 and my old projects.
One of them - basicaly an UI app which allows for upload of a few images from the camera roll and renders them into a UISceneView, litteraly makes Pythonista crash when my app gets the control back from the photo picker. At this part of the code, my app mostly unloads all previous images and reloads them. The crash happens randomly : most of the time it happens on the first try, sometimes it happens after 2,3 attempts.
Ironicaly, this app was running perfectly on the older Pythonista. When I launch it as a standalone scene and make multiple load/unloads of the same images, everything is fine too.
My initial guess is the UI module eats up a lot more memory than the previous version. I've tried to put a few gc.collect() in the code, with no luck.
The code is quite big and refers to a few external files, so it's hard to share it there. But I'd really appreciate some insights on a strategy to help me fixing this - as I loose the console output upon each crash :-(
Thanks !
-
you will probably need to post a gist if you want specific help, but I can offer a few bita of advice:
transitions between views, has in the past sometimes been problematic. ui.in_background sometimes was the culprit. In the past I would often suggest ui.delay over in_background for certain operations(although I am not sure if this still applies in current versions).
If you are showing the phot picker, then immediately presenting a scene or doing something else with a ui, a ui.delay to ensure that the photo picker dismiss animation is complete before presenting the next thing may be useful.
Is the crash a hard back to home screen crash? Or a screen freezes type of crash?
Can you post your code, or a minimal example -
Oh thanks for mentioning the ui.inbackground() stuff - that was the issue !
Actually my code was reloading all the images from a @ui.inbackground section, which is bad design.
Fixed it in order to ensure all is always loaded from the main thread, it works great now !
Sorry for bothering, and thanks for the super fast reply.