ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
557 stars 46 forks source link

Support marshalling OS_dispatch_queue on macOS 10.10 and 10.11. #220

Open ronaldoussoren opened 6 years ago

ronaldoussoren commented 6 years ago

Original report by WayneK (Bitbucket: WayneK, GitHub: WayneK).


Using PyObjC 4.0.1 on macOs 10.10.3 we're seeing an error below that doesn't occur on macOS 10.12.6:

#!python

initWithDelegate_queue_options_(self, queue_ptr, None)
ValueError: depythonifying 'pointer', got 'OS_dispatch_queue'

A standalone testcase is here: https://gist.github.com/WayneKeenan/8ce4d841158909ad441dc7312637a064

I would be interested to know if it can be worked around when using PyObjC 4.0.1 on macOS 10.10.x ?

Perhaps the upcoming PyObjC 4.1's added dispatch support means the workaround will go away and I wonder that because the Python/ObjC conversion isn't needed all will be ok on 10.10 as it is on 10.12 (?)

thanks Wayne

ronaldoussoren commented 6 years ago

Original comment by WayneK (Bitbucket: WayneK, GitHub: WayneK).


This also occurs on macOS 10.11.6.

ronaldoussoren commented 6 years ago

Original comment by WayneK (Bitbucket: WayneK, GitHub: WayneK).


After I reproduced the error on macOS 10.11, still using my ctypes method, I thought I would try the latest pyobjc code.

I've found this is also occuring using the PyObjC 4.1 libdispatch wrapper, please find a small test case is here: https://gist.github.com/WayneKeenan/f71525f1fd3839c485946590ae3ef81d

ronaldoussoren commented 6 years ago

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


This means I have to update metadata to ensure this works properly on macOS 10.10.

ronaldoussoren commented 6 years ago

Original comment by WayneK (Bitbucket: WayneK, GitHub: WayneK).


Would this be something that could make into the initial 4.1 release?

ronaldoussoren commented 6 years ago

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


That's the plan. I have VM's running various macOS releases and intent to do a full test run on 10.9 and later before releasing 4.1.

I'm currently working on bindings for the Security framework, I'll start the test run after that.

ronaldoussoren commented 6 years ago

Original comment by WayneK (Bitbucket: WayneK, GitHub: WayneK).


That's great news. Thank you.

ronaldoussoren commented 6 years ago

Original comment by WayneK (Bitbucket: WayneK, GitHub: WayneK).


The error is still occurring in 4.1:

#!python

 Uninstalling pyobjc-4.0.1:
      Successfully uninstalled pyobjc-4.0.1
Successfully installed pyobjc-4.1 pyobjc-core-4.1 pyobjc-framework-AVFoundation-4.1 pyobjc-framework-AVKit-4.1 pyobjc-framework-Accounts-4.1 pyobjc-framework-AddressBook-4.1 pyobjc-framework-AppleScriptKit-4.1 pyobjc-framework-AppleScriptObjC-4.1 pyobjc-framework-ApplicationServices-4.1 pyobjc-framework-Automator-4.1 pyobjc-framework-CFNetwork-4.1 pyobjc-framework-CalendarStore-4.1 pyobjc-framework-CloudKit-4.1 pyobjc-framework-Cocoa-4.1 pyobjc-framework-Collaboration-4.1 pyobjc-framework-CoreBluetooth-4.1 pyobjc-framework-CoreData-4.1 pyobjc-framework-CoreLocation-4.1 pyobjc-framework-CoreServices-4.1 pyobjc-framework-CoreText-4.1 pyobjc-framework-CoreWLAN-4.1 pyobjc-framework-CryptoTokenKit-4.1 pyobjc-framework-DictionaryServices-4.1 pyobjc-framework-DiskArbitration-4.1 pyobjc-framework-EventKit-4.1 pyobjc-framework-ExceptionHandling-4.1 pyobjc-framework-FSEvents-4.1 pyobjc-framework-FinderSync-4.1 pyobjc-framework-GameCenter-4.1 pyobjc-framework-GameController-4.1 pyobjc-framework-GameKit-4.1 pyobjc-framework-IMServicePlugIn-4.1 pyobjc-framework-IOSurface-4.1 pyobjc-framework-ImageCaptureCore-4.1 pyobjc-framework-InputMethodKit-4.1 pyobjc-framework-InstallerPlugins-4.1 pyobjc-framework-InstantMessage-4.1 pyobjc-framework-LatentSemanticMapping-4.1 pyobjc-framework-LaunchServices-4.1 pyobjc-framework-LocalAuthentication-4.1 pyobjc-framework-MapKit-4.1 pyobjc-framework-MediaAccessibility-4.1 pyobjc-framework-MediaLibrary-4.1 pyobjc-framework-MultipeerConnectivity-4.1 pyobjc-framework-NetFS-4.1 pyobjc-framework-NotificationCenter-4.1 pyobjc-framework-OpenDirectory-4.1 pyobjc-framework-PreferencePanes-4.1 pyobjc-framework-PubSub-4.1 pyobjc-framework-QTKit-4.1 pyobjc-framework-Quartz-4.1 pyobjc-framework-SceneKit-4.1 pyobjc-framework-ScreenSaver-4.1 pyobjc-framework-ScriptingBridge-4.1 pyobjc-framework-SearchKit-4.1 pyobjc-framework-Security-4.1 pyobjc-framework-SecurityFoundation-4.1 pyobjc-framework-SecurityInterface-4.1 pyobjc-framework-ServiceManagement-4.1 pyobjc-framework-Social-4.1 pyobjc-framework-SpriteKit-4.1 pyobjc-framework-StoreKit-4.1 pyobjc-framework-SyncServices-4.1 pyobjc-framework-SystemConfiguration-4.1 pyobjc-framework-WebKit-4.1 pyobjc-framework-iTunesLibrary-4.1 pyobjc-framework-libdispatch-4.1
(my-venv) eddies-computer:my-venv barry$ python3 -m bleson --observer
2017-12-11 21:02:23,052  ERROR -         macos_adapter.py:132 -          _runloop_thread(): depythonifying 'pointer', got 'OS_dispatch_queue'
Traceback (most recent call last):
  File "/Users/barry/development/my-venv/lib/python3.6/site-packages/bleson/providers/macos/macos_adapter.py", line 125, in _runloop_thread
    self._manager.initWithDelegate_queue_options_(self, queue_ptr, None)
ValueError: depythonifying 'pointer', got 'OS_dispatch_queue'
2017-12-11 21:02:23,086   INFO -         macos_adapter.py:133 -          _runloop_thread(): Exiting runloop
ronaldoussoren commented 6 years ago

Original comment by Antoine Martin (Bitbucket: totaam, GitHub: totaam).


Is there a workaround we can use until this is fixed?

ronaldoussoren commented 6 years ago

Original comment by WayneK (Bitbucket: WayneK, GitHub: WayneK).


Is there a fix in the works or planned? Thanks Wayne

ronaldoussoren commented 6 years ago

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


No, I haven't been able yet to reproduce the problem.

ronaldoussoren commented 6 years ago

Original comment by Antoine Martin (Bitbucket: totaam, GitHub: totaam).


@ronaldoussoren have you tried the test case above from @waynek ? Triggers for me every time, so does this one which is a bit longer but has the advantage of being self-contained: https://www.xpra.org/trac/attachment/ticket/1231/webcam_avfoundation.py

ronaldoussoren commented 6 years ago

Original comment by Antoine Martin (Bitbucket: totaam, GitHub: totaam).


@ronaldoussoren If somehow you are unable to reproduce it with the self-contained example I posted above against your local version of python, our packages include the python interpreter built from source (we have both 2.7.x and 3.6.x builds) and the required libraries so you can run the example from ./Xpra.app/Contents/Helpers/Python Just use the beta builds from xpra macos beta

ronaldoussoren commented 6 years ago

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


@totaam: Thanks. I'll try to reproduce it using your script and program.

ronaldoussoren commented 5 years ago

Original comment by Antoine Martin (Bitbucket: totaam, GitHub: totaam).


Bump. @ronaldoussoren this is still a problem with pyobjc 5.1.1 You can download any of our xpra macos builds and run the example with it. We have both python2 and python3.7 builds, both fail.

ronaldoussoren commented 5 years ago

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


I don't have time to look into this at the moment and the near future. I'm away from my computer for most of the month and will look into this in december.

ronaldoussoren commented 5 years ago

Original comment by Antoine Martin (Bitbucket: totaam, GitHub: totaam).


FYI: still erroring out with pyobjc 5.1.2

ronaldoussoren commented 5 years ago

Original comment by Antoine Martin (Bitbucket: totaam, GitHub: totaam).


I'm away from my computer for most of the month and will look into this in december.

Still a problem with pyobjc 5.2

Can you suggest a workaround?

ronaldoussoren commented 4 years ago

Original comment by Antoine Martin (Bitbucket: totaam, GitHub: totaam).


Still a problem with pyobjc 6.0.1

ronaldoussoren commented 4 years ago

Original comment by Antoine Martin (Bitbucket: totaam, GitHub: totaam).


Still a problem with pyobjc 6.1