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

osr: focus is lost after a redirection (thus causing the text cursor to be missing (caret) and the FocusEvent not being triggered) #3870

Open
Hethsron opened this issue Jan 16, 2025 · 3 comments
Labels
bug Bug report

Comments

@Hethsron
Copy link

Hethsron commented Jan 16, 2025

Describe the bug
Hello @magreenblatt

We recently encountered a problem with the focus in CEF. We had difficulty reproducing it because it rarely happened. But we're contacting you today because we've managed to find a simple scenario that you can easily reproduce.

To Reproduce
Steps to reproduce the behavior:

  1. Run cefclient using the following command to to https://duckduckgo.com
cefclient.exe --use-alloy-style --enable-chrome-runtime --off-screen-rendering-enabled --enable-logging=stderr --v=1 --url=https://duckduckgo.com
  1. Try to search something on the first page to be redirected on another.
  2. Write something in the new input field and clear it.
  3. Then click again in the input field, the carret, which originally appeared as a flashing vertical bar, is no longer displayed. But you can still type.

In our case, we observed this expected behaviour in a form created with VueJS. We had a drop-down list that wasn't displayed because the focus event hadn't been received, even though the activeElement property had changed.

We tested with Chrome and Edge and didn't have the problem. The problem only occurs when you activate the Chrome runtime with the Alloy style.

Expected behavior
We expect the behaviour to be in line with that of Chrome and Edge.

Video
https://github.com/user-attachments/assets/fbc9e37e-ce6e-4002-91ca-14be454da1fd

Impacted Version:

  • OS: Windows 10, MacOS 13.2, Ubuntu 22.10
  • CEF Version: 125, 126, 127, 128, 129, 130, 131, 132, 133 (using Chrome Runtime + Alloy Style)

Additional context
Yes, the problem is reproducible with cefclient as you can see.

@Hethsron Hethsron added the bug Bug report label Jan 16, 2025
@Hethsron Hethsron changed the title osr: offscreen-rendering : focus does not work as expected osr: chrome-runtime + alloy-style : focus does not work as expected Jan 16, 2025
@Hethsron Hethsron changed the title osr: chrome-runtime + alloy-style : focus does not work as expected osr: chrome-runtime + alloy-style : focus is not fired in some scenarios Jan 17, 2025
@24aligre
Copy link
Contributor

Maybe related to issue #3510 and #3436
If someone has any hint to help us starting to debug, we're very interested as we have blocking scenarios on such issue.

@24aligre
Copy link
Contributor

I've tried to start the debug by the callstack of the renderer process when CefRenderProcessHandler::OnFocusedNodeChanged is called but this method is actually callbacked correctly, even when the onfocus event is not fired.
Which code manages the focus in OSR mode ? where I can start the debug ?

@Hethsron
Copy link
Author

Hethsron commented Feb 4, 2025

Hello @magreenblatt

We found a workaround to this scenario that we can apply in OnLoadingStateChange as follows :

void ClientHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
                                    bool isLoading,
                                    bool canGoBack,
                                    bool canGoForward) {
    // Proposal 1
    CefRefPtr<CefFrame> frame = browser->GetFocusedFrame();
    if (frame->IsFocused() && !isLoading) {
        browser->GetHost()->SetFocus(true);
    }

    // Proposal 2
    CefRefPtr<CefFrame> frame = browser->GetFocusedFrame();
    if (frame->IsMain() && !isLoading) {
        browser->GetHost()->SetFocus(true);
    }
}

There is also an alternative to this using OnLoadEnd as described here: https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=20161

What do you think? Is this without risk?

However, we believe that redirection significantly disrupts focus as implemented in the internal layers of CEF/Chromium.

We are ready to help if you provide us with feedback on the subject, in order to achieve a more lasting solution than this bypass.

@Hethsron Hethsron changed the title osr: chrome-runtime + alloy-style : focus is not fired in some scenarios osr: focus is lost after a redirection (thus causing the text cursor to be missing (caret) and the FocusEvent not being triggered) Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report
Projects
None yet
Development

No branches or pull requests

2 participants