I’m playing around with integrating a UI info panda3D and I’m running into some weird issues on macOS. First, here’s a minimal example for reproducing my problem:
from cefpython3 import cefpython
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
class MyApp(ShowBase):
def __init__(self):
super().__init__()
self.disableMouse()
self.updateTask = self.taskMgr.add(self.updateTask, 'updateTask')
def updateTask(self, task):
if self.mouseWatcherNode.hasMouse():
x = self.mouseWatcherNode.getMouseX()
y = self.mouseWatcherNode.getMouseY()
print(x, y)
cefpython.MessageLoopWork()
return Task.cont
def main():
settings = {
"windowless_rendering_enabled": True,
}
switches = {
"disable-gpu": "",
"disable-gpu-compositing": "",
"enable-begin-frame-scheduling": "",
}
cefpython.Initialize(settings=settings, switches=switches)
app = MyApp()
app.run()
cefpython.Shutdown()
if __name__ == '__main__':
main()
When I run this, the mouse positions printed out are only updated when I have a mouse button clicked on the window. Has anyone encountered this before or have any insight into what might be going on here?
As a heads up, there are quite a few gotchas when using CEF with Panda, and you may want to take a look at cefpanda to handle some of those gotchas for you.
As for your question, this looks pretty similar to how the mouse is handled for cefpanda, and that works on Linux and Windows. I wonder if there is some macOS quirk here? Can you reproduce the issue without any of the CEF code in there?
Thanks for the reply! The example works as expected on Ubuntu 16.04 and Windows 10. So the weirdness only happens on MacOS 10.15.
I looked into cefpython and what they are doing differently is initializing cefpython after initializing panda3d. If I change the example to do that, then I get an “Illegal instruction: 4” error from cefpython. I get the same error if I try the cefpanda examples.
Just tested with Panda 1.10.4.1 and cefpython3 version 0.66 on MacOS Mojave (10.14.6) and your example works out of the box, when the mouse is in the window I get the mouse position in the console.
Maybe it’s another side effect of Catalina (yikes) or you are using an older version of panda or cefpython ?
That’s interesting! (Also yes yikes Catalina). I’ll have to double-check the versions when I get home this evening, but they were both the current pip versions.
So I just checked and I can confirm that I am using panda3d==1.10.4.1 and cefpython3==66.0. @eldee When you move the mouse you actually get different numbers, right? (for me it will print the positions every task update like it should, it’s just that the mouse manager doesn’t update its position until the mouse button is pressed).
Alright I think I can actually reproduce this using cefpython’s pysdl example. @eldee Do you think I could get you to try it on Mojave for me? It would be a great help because then I could take this over to cefpython’s forums. It requires the following dependencies:
brew install sdl2
pip install pysdl2
You can get the cefpython repo from
https://github.com/cztomczak/cefpython.git
and then apply this diff to make the example work in python 3:
When you have it open, the google search bar should have the cursor. Click out, then hover your mouse over the search bar and you should see the search bar highlight. (for me it only does it with the mouse button down).
The search bar gets highlighted when I hover over it (without any action from the mouse button). So your guess is correct, the problem is in cef (or cefpython) under Catalina.