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

QT5 support to run on macOS 10.12.x (and other OS) #269

Closed
sighmon opened this issue Oct 29, 2016 · 20 comments
Closed

QT5 support to run on macOS 10.12.x (and other OS) #269

sighmon opened this issue Oct 29, 2016 · 20 comments
Milestone

Comments

@sighmon
Copy link

sighmon commented Oct 29, 2016

Trying brew install qt on macOS 10.12.1 now gives the widely reported: This formula either does not compile or function as expected on macOS versions newer than El Capitan due to an upstream incompatibility.

Installing brew install qt5 works fine.

Are there any plans to update this repo to support QT5?

I did some find/replace from source, but notice that QtWebKit isn't included anymore: from PyQt5 import QtWebKit ImportError: cannot import name 'QtWebKit' :-(

So the migration process might be a little more involved.

@ataffanel
Copy link
Member

So far we found no reason to move to Qt5 but this sounds like a good one. Do you think it will help packaging the app for Mac? (see ticket #231, I passed a lot of time trying to fix that without success ...)

Our usage of webkit is limited to a single tab so I would not be too worried about that (and we use it for the GPS map that does not work anymore so we have to fix it anyway).

If you remove the gps tab, does it look easy to port?

@sighmon
Copy link
Author

sighmon commented Oct 31, 2016

@ataffanel A packaged app would be awesome - but in the meantime I've got the initial interface running with QT5, and can connect to my crazyflie, but I can't get the input devices tab to work.

https://github.com/sighmon/crazyflie-clients-python/tree/qt5

This is the file that crashes out: src/cfclient/ui/dialogs/inputconfigdialogue.py

Error:

QObject::connect: Incompatible sender/receiver arguments
        QTimer::timeout() --> DeviceReader::mapped_values_signal(PyQt_PyObject)
Traceback (most recent call last):
  File "/Users/sighmon/Coding/crazyflie quadcopter/cfclient-2016.4.1/src/cfclient/ui/main.py", line 544, in _show_input_device_config_dialog
    self.inputConfig = InputConfigDialogue(self.joystickReader)
  File "/Users/sighmon/Coding/crazyflie quadcopter/cfclient-2016.4.1/src/cfclient/ui/dialogs/inputconfigdialogue.py", line 61, in __init__
    self._input_device_reader = DeviceReader(self._input)
  File "/Users/sighmon/Coding/crazyflie quadcopter/cfclient-2016.4.1/src/cfclient/ui/dialogs/inputconfigdialogue.py", line 456, in __init__
    self.start(self._read_timer, self._read_timer.timeout.connect(tofix), self._read_input)
TypeError: connect() failed between timeout() and mapped_values_signal()
Abort trap: 6

I'm not sure what I'm supposed to be handing in to self._read_timer.timeout.connect(?)

It's also crashing on disconnect:

INFO:cflib.crazyflie:Callback->Disconnected from [radio://0/48/250K]
Traceback (most recent call last):
  File "/Users/sighmon/Coding/crazyflie quadcopter/cfclient-2016.4.1/src/cfclient/ui/tabs/ParamTab.py", line 258, in _disconnected
    self._model.reset()
  File "/Users/sighmon/Coding/crazyflie quadcopter/cfclient-2016.4.1/src/cfclient/ui/tabs/ParamTab.py", line 220, in reset
    super(ParamBlockModel, self).reset()
AttributeError: 'super' object has no attribute 'reset'
Abort trap: 6

And it doesn't actually seem to be receiving (or maybe just displaying) data back from the crazyflie when connected.. but it starts, so that's something. :-)

@ataffanel
Copy link
Member

Thanks! I am testing your branch to see if I can help.

I found that pyQT5 is finally available in pypi so it can be installed with pip, this was the most problematic dependency and so we might soon be able to install cfclient with just pip install cfclient on most systems!

One first problem I encounter is that QtWebEngineWidgets is not part of ubuntu/debian yet: https://bugs.launchpad.net/ubuntu/+source/qtbase-opensource-src/+bug/1579265. But there is a package called python3-pyqt5.qtwebkit so it seems that qtwebkit is still part or pyqt5.

For now, I am disabling the gps tab and testing the rest.

@ataffanel
Copy link
Member

ataffanel commented Nov 1, 2016

I have pushed a couple of fix:

  • The main window was displayed in a weird place (I have 2 screens) so I added code to center the window on the current screen
  • Add qt/pyqt version to about box
  • Fix the gamepad mapping tab.

For me getting data from the Crazyflie and flying works well.

I am investigating the crash at disconnect and I found new problems that I am looking at too:

  • The log toc tab is not working
  • The Plot tab is not working (pyqtgraph has not released any version supporting qt5, works by pip installing the pyqtgraph git)
  • Scan button is not working

I am pushing commits on a clone of your branch: https://github.com/ataffanel/crazyflie-clients-python/tree/qt5. If you pull my changes we can work on the same code.

@sighmon
Copy link
Author

sighmon commented Nov 2, 2016

@ataffanel Awesome, thanks. I've pulled that in now, but when my PS3 remote is connected via Bluetooth or USB it crashes cfclient with error:

INFO:cfclient.utils.input.inputreaders.pysdl2:Found 1 devices
INFO:cfclient.utils.input:Selected MUX: Normal
INFO:cfclient.ui.main:Role of PLAYSTATION(R)3 Controller is Device
INFO:cfclient.utils.input.mux:Adding device PLAYSTATION(R)3 Controller to MUX Normal
INFO:cfclient.ui.main:Select first device
2016-11-02 19:13:50.205 Python[29959:12287919] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff8765148b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fff9bdb3cad objc_exception_throw + 48
    2   AppKit                              0x00007fff8596450c -[NSApplication(NSEvent) shouldBeTreatedAsInkEvent:] + 0
    3   libSDL2.dylib                       0x0000000109f4a3bf Cocoa_PumpEvents + 254
    4   libSDL2.dylib                       0x0000000109eedb48 SDL_PumpEvents_REAL + 23
    5   _ctypes.cpython-35m-darwin.so       0x0000000109e6e79f ffi_call_unix64 + 79
    6   ???                                 0x000070000c5993e0 0x0 + 123145509508064
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

@ataffanel
Copy link
Member

I saw crash yesterday, it is great that you got a trace since I got nothing. Now there is a chance to find what it is at least. This seems to be about the threads. we have a lot of threads running in the client and apparently MacOS is not happy about running something outside of the main thread, now we need to find what this something is and why it was not a problem with Qt4.

@sighmon
Copy link
Author

sighmon commented Nov 6, 2016

@ataffanel the trace didn't help me much though.. I haven't done a lot of python debugging, and couldn't find the thread call that was throwing the NSInternalInconsistencyException.

@ataffanel
Copy link
Member

The trace comes directly from Mac-os, apparently we are calling GUI things in non-gui context. Maybe related to my changes with the timer, it definitely seems to come from SDL in any case not from QT.

One thing I can think off would be to put all signals related to the gamepad in the main thread context. QT will then execute the signal handler in the main thread.

@dgellow
Copy link

dgellow commented Dec 28, 2016

Any news?

@sighmon
Copy link
Author

sighmon commented Dec 29, 2016

@dgellow I don't know enough about QT5 threading to know how to fix the problems, sorry! So it's in the hands of @ataffanel for now.

@ataffanel
Copy link
Member

There is still the same problem related to threads (more related to the OS than to QT, its mac OS that is crashing us).

By the way I discovered that miniconda (the python environment I use on Windows) works on Mac to run the QT4 client, but I saw a bug so maybe some other mac could test to see if the bug comes from my machine or from QT4: #273.

mikezter added a commit to mikezter/crazyflie-clients-python that referenced this issue Jan 27, 2017
* develop:
  bitcraze#280 Refactoring of input device config file handling.
  Changed name of LoPo graph (bitcraze#276)
  Enable the Loco Positioning tab. Closes bitcraze#276
  bitcraze#276 Improved scaling/scrolling of graphs in Lo Po tab. Supporting variable nr of anchors by only subscribing to available ranges.
  Changed layout of local positioning tab (bitcraze#276)
  bitcraze#276 Change size of anchors when highlighted
  bitcraze#276 Added dynamic color of anchors to show that the copter is in the vicinity of an anchor
  bitcraze#276 Added basic graphing of anchors and position for the Loco Positioning tab
  Added “Clear” and “Task dump” buttons to the console tab. Closes bitcraze#278
  bitcraze#276 Fixed flake8 problem
  bitcraze#276 Logging of estimated position in LoPo tab
  bitcraze#227 Removed examples that have been moved to the lib
  bitcraze#269 Collecting anchor positions and ranges in the LoPo tab
  bitcraze#276 Spike for the Loco Positioning tab
  bitcraze#269 Updated readme with information for OS X on pyqt 4 VS 5
  Update readme.md with windows pycharm setup
  Closes bitcraze#275: Save and restore main window size
  use all joystick hat motions and extract method
  Add Arnaud's suggestions
  Add QScrollArea to support resizing the main window
@krichardsson
Copy link
Contributor

I ran into a problem on my Mac where I had QT4 working and then installed QT5. After that QT4 stopped working and further more it turned out to be impossible(?) to fix QT4 again. In my opinion QT5 is becoming urgent.

This is also a warning to Mac users (and possibly other OSes), if you have QT4 working with the client, do not install QT5 as it might mess up QT4.

@krichardsson
Copy link
Contributor

We are using the dev-pyqt5 branch for the work of converting to QT5. We are trying to finish it this week and have decided to document any issues we see as comments in this ticket during this week. If any problems remain after this week we will create separate issues at that point.

@krichardsson
Copy link
Contributor

krichardsson commented Mar 16, 2017

Problem report

In the plot tab, when choosing a new configuration the parameters in the previous config are not removed from the legend in the plot graph.

Seen on MacOS and Windows

Fixed. Works on Mac, needs to be verified on windows and linux. Works on all platforms

@krichardsson
Copy link
Contributor

krichardsson commented Mar 16, 2017

Problem report

The menus View/Tabs and View/Toolboxes are disabled

Seen on MacOS
No problem on Windows and Linux

Fixed

Verified on MacOS, Win and linux

@krichardsson
Copy link
Contributor

krichardsson commented Mar 16, 2017

Problem report

The "Configure input device" dialog is too small when opened, some controls are almost outside the dialog. The text in the "Configure" button is too wide.

Seen on MacOS
No problem on Windows

Fixed. Increased height of the dialog slightly. The dialog does not have a dynamic resize behavior and probably needs a full make over, but that is out of scope for this issue.

@ataffanel
Copy link
Member

ataffanel commented Mar 16, 2017

Problem report Fixed

Windows build needs adjustement

  • Removing one folder in pyqt is still required, needs to be converted to pyqt5
  • We need to copy one extra file manually from pyqt install path to the dist folder: Library\plugins\platforms\qwindows.dll

With that two fix, the installer is verified to work.

For Windows

@ataffanel
Copy link
Member

ataffanel commented Mar 16, 2017

TODO

We need to update readme instructions for

  • Windows
  • Mac
  • Linux

ataffanel pushed a commit that referenced this issue Mar 16, 2017
@krichardsson
Copy link
Contributor

krichardsson commented Mar 16, 2017

Remove the fix for Repaint problem #260

It seems as the repaint problem we used to have has gone.

Fixed

@ataffanel
Copy link
Member

The Qt5 port is finally completed and merged! Thanks @sighmon for the original port and help.

@ataffanel ataffanel added this to the Next release milestone Apr 20, 2017
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

4 participants