chromiumembedded / cef

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

[OSR/Touch] Scrolling initiated by touch events aborted after "navigation within document" occurs #2936

Open magreenblatt opened 4 years ago

magreenblatt commented 4 years ago

Original report by Dmitry Azaraev (Bitbucket: dmitry-azaraev, GitHub: dmitry-azaraev).


When we perform touch-scrolling sequence, if in this time page will set document.location.hash, then scrolling immediately stops. If you will try reproduce same with devtools sensors emulation - it will work fine. I’m reproduced this on CEF78 and current CEF master.

How to reproduce:

  1. Modify cefclient (it is fastest way):
// In file: `cef/tests/cefclient/browser/test_runner.cc` replace method body.

void RunOtherTests(CefRefPtr<CefBrowser> browser) {
  // Run on some another thread which we can block as we want
  // Because we use Sleep, and this is important to indirectly define scroll speed/power.
  if (!CefCurrentlyOn(TID_FILE_USER_BLOCKING)) {
    CefPostTask(TID_FILE_USER_BLOCKING, base::Bind(&RunOtherTests, browser));
    return;
  }

  int delayMs = 20;

  CefTouchEvent te;
  te.id = 0;
  te.x = 300;
  te.y = 300;
  te.type = CEF_TET_PRESSED;

  auto host = browser->GetHost();
  host->SendTouchEvent(te);

  for (int i = 0; i < 200; i++) {
    te.x = 300 - i;
    te.y = 300;
    te.type = CEF_TET_MOVED;
    host->SendTouchEvent(te);
    Sleep(delayMs);
  }

  te.x = 300 - 200;
  te.type = CEF_TET_RELEASED;
  host->SendTouchEvent(te);
  Sleep(delayMs);
}

2. Run cefclient --off-screen-rendering-enabled

3. Load one of attached files: cef-carousel.html , and run Tests->Other Tests… , it will slowly scroll layer and should stop with ScrollLeft value around 185..186.

4. Load another file: cef-carousel-hashed.html , and run Tests->Other Tests… , it will stop scroll almost immediately, and show some number (usually less than 10).

cef-carousel-hashedonly listen scroll event and perform navigation within document (via document.location.hash = v;). Events generated by devtools emulation and snipped above seems to be identical. The only thing what in one case changing hash is break scrolling and in other case it is not.

PS: This is not uncommon technique, exactly google search may update document.location in same way when you trying to g-scrolling-carousel. However test this over google search is much harder, and requires additional preparations.

magreenblatt commented 4 years ago

Original comment by Dmitry Azaraev (Bitbucket: dmitry-azaraev, GitHub: dmitry-azaraev).


Pull request #317 has fix.

magreenblatt commented 4 years ago

Original changes by Dmitry Azaraev (Bitbucket: dmitry-azaraev, GitHub: dmitry-azaraev).


magreenblatt commented 4 years ago

Original changes by Dmitry Azaraev (Bitbucket: dmitry-azaraev, GitHub: dmitry-azaraev).


magreenblatt commented 4 years ago

Original changes by Dmitry Azaraev (Bitbucket: dmitry-azaraev, GitHub: dmitry-azaraev).