chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.39k stars 467 forks source link

osr: windows: custom cursors deleted directly after passing to OnCursorChange #3728

Open markus-neff-bl opened 4 months ago

markus-neff-bl commented 4 months ago

Bug description In CEF OSR mode, (custom) cursors are passed to the host application via "CefDisplayHandler::OnCursorChange". The call comes from "cursor_util::OnCursorChange", where before being passed out, the cursor is put into a ScopedCursorHandle. The "naked" cursor handle is passed out to the host, so there is no chance for participation in ref-counting or similar.

This leaves the host application with a handle that directly after "CefDisplayHandler::OnCursorChange" becomes invalid.

If the application sets the windows application Cursor e.g. via "SetCursor", the cursor changes but afterwards, the OS seems to also have a "dangling reference" to the cursor. This can be observed with calling "GetCursorInfo", which returns an error in this situation.

Applications like Barco ClickShare which use "GetCursorInfo" to get and transmit the cursor this way cannot capture and therefore not display the cursor shape on the remote display.

For system cursors, the problem does not surface as those standard cursor handles cannot be deleted and stay valid.

To Reproduce

  1. Start cefclient in OSR mode
  2. Browse to a html page that uses custom cursors
  3. In another application, repeatedly call "GetCursorInfo"
  4. See call failing with a windows error code

Expected behavior Expectation would be that one can either take ownership of the returned cursor handle or participate in shared ownership. The workaround is to clone the cursor in the callback, which is not very nice.

Versions (please complete the following information):

Additional context The problem can be reproduce with the cefclient application.