beeware / toga

A Python native, OS native GUI toolkit.
https://toga.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
4.36k stars 671 forks source link

DeprecationWarning: There is no current event loop, on iOS #1746

Closed coolcoder613eb closed 1 year ago

coolcoder613eb commented 1 year ago

Describe the bug

when running this on an ios simulator, no text is displayed.

Steps to reproduce

  1. clone https://github.com/coolcoder613eb/beeware-console
  2. cd to console/
  3. run briefcase run ios
  4. compare to to briefcase run

Expected behavior

my app, which uses asyncio, to work. the text should be displayed, and and update on the button press.

Screenshots

No response

Environment

Logs

TAB118192:beeware-console bhumkarp$ ls
LICENSE README.md codemagic.yaml console logs
TAB118192:beeware-console bhumkarp$ cd console/
TAB118192:console bhumkarp$ python3 -m briefcase run iOS -u --log

[console] Updating application code...
Installing src/console... done

[console] Removing unneeded app content...
No app content clean up required.

[console] Application updated.

Select simulator device:

  1) iPad (9th generation)
  2) iPad Air (4th generation)
  3) iPad Pro (11-inch) (3rd generation)
  4) iPad Pro (12.9-inch) (5th generation)
  5) iPad Pro (9.7-inch)
  6) iPad mini (6th generation)
  7) iPhone 11
  8) iPhone 11 Pro
  9) iPhone 11 Pro Max
  10) iPhone 12
  11) iPhone 12 Pro
  12) iPhone 12 Pro Max
  13) iPhone 12 mini
  14) iPhone 13
  15) iPhone 13 Pro
  16) iPhone 13 Pro Max
  17) iPhone 13 mini
  18) iPhone 8
  19) iPhone 8 Plus
  20) iPhone SE (2nd generation)
  21) iPod touch (7th generation)

> 1

In the future, you could specify this device by running:

    $ briefcase build iOS -d "iPad (9th generation)::iOS 15.2"

or:

    $ briefcase build iOS -d 840296DE-FDD1-417B-A05B-8F090E620267

[console] Targeting an iPad (9th generation) running iOS 15.2 (device UDID 840296DE-FDD1-417B-A05B-8F090E620267)

[console] Building XCode project...
objc[62731]: Class RemoteXPCPair is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff2708) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64c238). One of the two will be used. Which one is undefined.
objc[62731]: Class RemoteXPCShim is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff2780) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64c2b0). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury11XPCEndpoint is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff2e58) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64c920). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury15XPCPeerEndpoint is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff2ef8) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64c9c0). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury19XPCListenerEndpoint is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff2f98) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64ca60). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury16XPCObjectEncoder is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff30a8) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64cb70). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury17_XPCObjectEncoder is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff3150) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64cc18). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury16XPCObjectDecoder is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff3200) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64ccc8). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury17_XPCObjectDecoder is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff32a8) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64cd70). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury14XPCSideChannel is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff35e8) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64d0b8). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury19RemoteDeviceBrowser is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff3730) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64d208). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury17XPCFileDescriptor is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff38b0) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64d388). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury12RemoteDevice is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff3b00) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64d5d0). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury13XPCConnection is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff3d20) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64d820). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury19RemoteXPCConnection is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff3ee8) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64d9e0). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury27RemoteXPCListenerConnection is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff4040) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64db30). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury23RemoteXPCPeerConnection is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff41e8) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64dcd0). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury19SystemXPCConnection is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff4a98) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64e578). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury27SystemXPCListenerConnection is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff4be0) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64e6c0). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury23SystemXPCPeerConnection is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff4d50) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64e830). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7Mercury15XPCFileTransfer is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff4fa8) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64ea70). One of the two will be used. Which one is undefined.
objc[62731]: Class _TtC7MercuryP33_2B1830E49151A2D290BADAC81D16B73411_HandlerBox is implemented in both /Library/Developer/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x117ff2ae8) and /Library/Apple/System/Library/PrivateFrameworks/Mercury.framework/Versions/A/Mercury (0x11f64c618). One of the two will be used. Which one is undefined.
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in dependency order
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the Console editor. (in target 'Console' from project 'Console')
Building... done

[console] Built iOS/Xcode/Console/build/Debug-iphonesimulator/Console.app

[console] Starting app on an iPad (9th generation) running iOS 15.2 (device UDID 840296DE-FDD1-417B-A05B-8F090E620267)
Booting simulator... done
Opening simulator... done

[console] Installing app...
Uninstalling any existing app version... done
Installing new app version... done

[console] Starting app...
com.example.console.console: 63049
Launching app... done

[console] Following simulator log output (type CTRL-C to stop log)...
===========================================================================
Error from getpwuid_r: 0 (Undefined error: 0)
Filtering the log data using "senderImagePath ENDSWITH "/Console" OR (processImagePath ENDSWITH "/Console" AND senderImagePath ENDSWITH "-iphonesimulator.so")"
Timestamp               Ty Process[PID:TID]
2023-01-19 05:47:24.632 Df Console[63049:13316aa] Configuring isolated Python...
2023-01-19 05:47:24.634 Df Console[63049:13316aa] PythonHome: /Users/bhumkarp/Library/Developer/CoreSimulator/Devices/840296DE-FDD1-417B-A05B-8F090E620267/data/Containers/Bundle/Application/7CF7D481-1E10-48D8-A5E3-EC71E7427DAE/Console.app/python-stdlib
2023-01-19 05:47:24.635 Df Console[63049:13316aa] PYTHONPATH:
2023-01-19 05:47:24.636 Df Console[63049:13316aa] - /Users/bhumkarp/Library/Developer/CoreSimulator/Devices/840296DE-FDD1-417B-A05B-8F090E620267/data/Containers/Bundle/Application/7CF7D481-1E10-48D8-A5E3-EC71E7427DAE/Console.app/python-stdlib
2023-01-19 05:47:24.636 Df Console[63049:13316aa] - /Users/bhumkarp/Library/Developer/CoreSimulator/Devices/840296DE-FDD1-417B-A05B-8F090E620267/data/Containers/Bundle/Application/7CF7D481-1E10-48D8-A5E3-EC71E7427DAE/Console.app/python-stdlib/lib-dynload
2023-01-19 05:47:24.636 Df Console[63049:13316aa] - /Users/bhumkarp/Library/Developer/CoreSimulator/Devices/840296DE-FDD1-417B-A05B-8F090E620267/data/Containers/Bundle/Application/7CF7D481-1E10-48D8-A5E3-EC71E7427DAE/Console.app/app_packages
2023-01-19 05:47:24.637 Df Console[63049:13316aa] - /Users/bhumkarp/Library/Developer/CoreSimulator/Devices/840296DE-FDD1-417B-A05B-8F090E620267/data/Containers/Bundle/Application/7CF7D481-1E10-48D8-A5E3-EC71E7427DAE/Console.app/app
2023-01-19 05:47:24.637 Df Console[63049:13316aa] Configure argc/argv...
2023-01-19 05:47:24.637 Df Console[63049:13316aa] Initializing Python runtime...
2023-01-19 05:47:24.928 Df Console[63049:13316aa] Installing Python NSLog handler...
2023-01-19 05:47:24.967 Df Console[63049:13316aa] Running app module: console
2023-01-19 05:47:26.096 Df Console[63049:13316aa] (_ctypes.cpython-310-iphonesimulator.so) /Users/bhumkarp/Library/Developer/CoreSimulator/Devices/840296DE-FDD1-417B-A05B-8F090E620267/data/Containers/Bundle/Application/7CF7D481-1E10-48D8-A5E3-EC71E7427DAE/Console.app/app_packages/toga_iOS/app.py:95: DeprecationWarning: There is no current event loop
2023-01-19 05:47:26.097 Df Console[63049:13316aa] (_ctypes.cpython-310-iphonesimulator.so)   self.loop = asyncio.get_event_loop()
2023-01-19 05:47:26.127 Df Console[63049:13316aa] (_ctypes.cpython-310-iphonesimulator.so) App finished launching.
2023-01-19 05:47:26.265 Df Console[63049:13316aa] (_ctypes.cpython-310-iphonesimulator.so) [iOS] Not implemented: TextInput.clear_error()
2023-01-19 05:47:26.265 Df Console[63049:13316aa] (_ctypes.cpython-310-iphonesimulator.so) [iOS] Not implemented: TextInput.set_on_lose_focus()
2023-01-19 05:47:26.266 Df Console[63049:13316aa] (_ctypes.cpython-310-iphonesimulator.so) [iOS] Not implemented: TextInput.set_on_gain_focus()
2023-01-19 05:47:26.317 Df Console[63049:13316aa] (_ctypes.cpython-310-iphonesimulator.so) [iOS] Not implemented: Window.set_title()
2023-01-19 05:47:26.414 Df Console[63049:13316aa] (_ctypes.cpython-310-iphonesimulator.so) App became active.

Additional context

No response

freakboy3742 commented 1 year ago

Firstly - the example code you've provided doesn't exist (or, at least, the repo isn't readable by me).

Secondly - "Here's a dump of my project" isn't a particularly helpful bug report. Part of a good bug report is reducing the problem to a simple reproduction case. That way someone debugging the problem doesn't need to come up to speed with the entire concept and implementation of a (potentially complex) application just to provide debugging help.

Lastly - I'm willing to bet that this is an error of usage. Depending on how you use it, a loop may not exist at the point you're trying to. However, without example code, it's impossible to say.

coolcoder613eb commented 1 year ago

sorry, wrong link. it run on windows, macos, linux, and android

freakboy3742 commented 1 year ago

Like I said - "my project doesn't work" isn't a particularly helpful bug report, as I know nothing about the rest of your project, and I'm not a huge fan of running large unknown project codebases on my own machine. What we need is a minimal reproduction case.

There's a possibility that the problem you're seeing will be fixed by beeware/rubicon-objc#238 - that fix corrected some problems with asyncio loops on iOS; but without doing a full teardown of your project, I can't say.

coolcoder613eb commented 1 year ago

how can i use that pull request?

coolcoder613eb commented 1 year ago

when will there be a release?

coolcoder613eb commented 1 year ago

I am using self.add_background_task

freakboy3742 commented 1 year ago

add_background_task() works; the handlers example demonstrates it working. There's clearly something else going on that is causing the problem you're seeing.

freakboy3742 commented 1 year ago

Closing due to a lack of response.