cefpython icon indicating copy to clipboard operation
cefpython copied to clipboard

Kivy - SendMouseMoveEvent with modifier not working

Open hoba87 opened this issue 4 years ago • 24 comments

When trying to integrate cefpython into kivy, the SendMouseMoveEvent with the modifier for a pressed MouseButton, e.g. cef.EVENTFLAG_LEFT_MOUSE_BUTTON, is not working for me.

See also the pull request for the updated kivy example https://github.com/cztomczak/cefpython/pull/573, which let me run the example on Win10.

For an easy check, the website http://nglviewer.org/ngl/?script=showcase/ferredoxin is good, which allow to rotate and move the structure by a pressed mouse button and mouse move in a webbrowser, but not with the kivy example.

Is there a solution or workaround?

hoba87 avatar May 15 '20 15:05 hoba87

Are you reporting issue with the kivy_.py example? This example is supported only on Linux.

cztomczak avatar May 15 '20 15:05 cztomczak

Yes, I know that it was not intended to support other OS, however with the new pull request commit, it is at least also working on Windows now, except this described issue. Can you confirm, that this issue is not present on Linux?

hoba87 avatar May 18 '20 10:05 hoba87

Are you running the kivy_.py example from the PR as is, or did you make any other modifications? What exactly isn't working, dragging?

cztomczak avatar May 18 '20 11:05 cztomczak

EDIT: To open the website mentioned above, I comment out the browser switches: "disable-gpu": "", "disable-gpu-compositing": ""

The "touch move" is not working, so moving the mouse while pressing left or right mouse button. Dragging is also not working. Or to say what it working: Clicking with the mouse and using the keyboard on Windows.

hoba87 avatar May 18 '20 13:05 hoba87

Do you need to comment out the browser switches to reproduce the issue?

cztomczak avatar May 18 '20 16:05 cztomczak

To open the website from above yes, because it uses WebGL, otherwise I get only the message that WebGL is not supported. The pywin32.py example works with the website by the way.

hoba87 avatar May 19 '20 09:05 hoba87

Can you test a different website with SendMouseMoveEvent ? With no modifications to kivy_.py (just as is in PR).

cztomczak avatar May 19 '20 10:05 cztomczak

Do you know a website where I can test it? I've googled around but have not find another one.

What I've tried: click on the google logo on google.com and "move" it. It works on MacOS, however it seems to be a drag event. (E.g. dragging an image to google pic search does not work) On Windows I get an error:

Traceback (most recent call last):
  File "render_handler.pyx", line 263, in cefpython_py36.RenderHandler_StartDragging
  File "C:/cefpython/src/linux/binaries_64bit/kivy_.py", line 964, in StartDragging
    drag_data, x, y, cef.DRAG_OPERATION_EVERY)
  File "browser.pyx", line 788, in cefpython_py36.PyBrowser.DragTargetDragEnter
OverflowError: can't convert negative value to uint32_t

hoba87 avatar May 19 '20 10:05 hoba87

Ah, ok after thinking again I've tried google maps. Yes it is working both on MacOS and Win. So do you have an idea what is the problem about the website from above?

hoba87 avatar May 19 '20 11:05 hoba87

If you remove the disable-gpu* flags rendering can be much slower. It might be that CPU is overloaded and events are being lost. Try lower frame rate.

I am not sure why WebGL doesn't work. v66 includes swiftshader (unless you've removed the swiftshader/ subdirectory in the cefpython3 package) which provides software rendering for GPU.

cztomczak avatar May 19 '20 11:05 cztomczak

Ok, for Windows the website is also loading with disable-gpu* flags, it seems I've tested that only on Mac before. However the touch move is not working, neither on mac nor on win with soft- or hardware rendering. Lowering the frame rate doesn't help and the cpu is not overloaded.

hoba87 avatar May 19 '20 12:05 hoba87

So now it's an issue with Kivy's on_touch_move, not with SendMouseMoveEvent?

cztomczak avatar May 19 '20 12:05 cztomczak

Well, probably it is not an issue with kivys on_touch_move because it is executed as verified by using google maps (and by adding a print command printing something). And perhaps also not an issue with SendMouseMoveEvent, also because of google maps test. The website from above is mainly based on javascript, could there be the issue?

hoba87 avatar May 19 '20 12:05 hoba87

You will have to debug it to find the cause of the issue.

cztomczak avatar May 19 '20 12:05 cztomczak

See if there are any errors in Developer Tools console.

cztomczak avatar May 19 '20 13:05 cztomczak

Arghh, it's a Heisenbug. When I use the ShowDevTools() function, it is working, both on Win and Mac. It also keeps working if I close the dev tools manually or by CloseDevTools(). The "direct" remote_debugging_port doesn't work (the link is there, but opens an empty site only) and doesn't help. The DevTools for Node works also like a Heisenbug, when the DevTools are opened, I can rotate the structure.

I'm not familiar with the DevTools but I cannot see any errors.

hoba87 avatar May 19 '20 14:05 hoba87

Check if message loop work is being called every 10ms or so. Looks like events are lost due to message loop not working correctly. Try enabling external_message_pump on other OSes and see if it makes any difference. When you open devtools in a window that uses windowed rendering it could affect message loop somehow.

Edited.

cztomczak avatar May 19 '20 14:05 cztomczak

the _meesage_loop_work function is called about every 5ms. external_message_pump does not make a difference for win.

hoba87 avatar May 19 '20 14:05 hoba87

5ms would be too often and might cause issues.

cztomczak avatar May 19 '20 14:05 cztomczak

changing it to about 10ms by removing the kivy "hack" makes no difference

hoba87 avatar May 19 '20 14:05 hoba87

EDIT: I've tested the workaround again, it keeps working only on Mac after CloseDevTools(). On Windows it works only with opened dev tools. Nevertheless, should I add the workaround to the pull request? Thank you for your help so far, but at the moment I have no clue what to try else.

hoba87 avatar May 25 '20 08:05 hoba87

What workaround?

cztomczak avatar May 25 '20 10:05 cztomczak

using ShowDevTools() CloseDevTools()

hoba87 avatar May 25 '20 11:05 hoba87

No, I don't think so. You can try creating a hidden window on startup and see if that helps. A hidden window using windowed rendering with CEF browser embedded.

Edited.

cztomczak avatar May 25 '20 11:05 cztomczak