Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-60673

Race Condition when Clearing Search to generate a selection

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.10.0 Beta 1
    • 5.8.0, 5.9.0 Beta 3, 5.9
    • WebEngine
    • None
    • gentoo, arch linux (docker), x86_64
    • 9d962bc9424c71a451d04741619c9597f3da8010

    Description

      This is my first time submitting a bug to qt, so please excuse any mistakes.

      This issue is a race condition when clearing found text in qtwebengine, via findNext("");. In qtwebengine 5.7.1, clearing found text resulted in the selected text being converted to a normal blue browser selection, which can be copied via ctrl-c and read through javascript. In qtwebengine 5.8.0 and 5.9.0 beta3 (web installer) this behavior is flaky, and results in the found text being converted to a selection about 1/4 of the time or less.

      To debug this, I built a few versions of qt and compared them, and found that debug versions (ones built with -developer-build and -debug in their configure flag) do not have this bug. In order to reproduce this, those flags must be removed while configuring.

      In order to reproduce this, I applied the attached patch to browsermainwindow.cpp of the qtwebengine demo browser, to modify the behavior of findPrevious to instead clear the selection.

      After a bit of looking around, the line that seems to be causing the race condition is qtwebengine/src/core/web_contents_adapter.cpp:903, which was added to solve QTBUG-54071. Commenting out that line (2nd attached patch) solves the problem and restores the desired functionality, but of course, leaves QTBUG-54071 broken (so this is NOT a good patch).

      Configure flags that do NOT have a flaky search behavior: ./configure -confirm-license -opensource -developer-build -debug -skip qtwebkit -skip qtlocation -nomake tests -nomake examples -icu -ssl
      Configure flags that do have flaky behavior: ./configure -confirm-license -opensource -prefix qtbase -skip qtwebkit -skip qtlocation -nomake tests -nomake examples -icu
      Make command: make module-qtwebengine -j7

      Steps to Reproduce:

      1. Compile qt5.8, 5.9, or 5.9beta3 without -developer-build and -debug, or use the respective web installers
      2. Apply browsermainwindow.cpp.patch, which is attached to browsermainwindow.cpp in the qtwebengine demo browser.
      3. Compile and start browsermainwindow.cpp
      4. On the qt homepage (default start page), search for qt, learn, etc.
      5. Press Shift-F3 to clear the selection. Repeat a couple of times.

      Expected Behavior:

      Every search clear should produce a blue selection, which can be copied via ctrl-c

      Actual Behavior:

      Most of the time, no selection appears, but occasionally, it does.

      Platforms where I cannot reproduce this bug: qt5.7.1 (webinstaller), qt5.9(with debug flags), qt5.9.0 beta3 (with debug flags, via The-Compiler)
      Platofrms where I can reproduce this bug: qt5.8.0 (webinstaller), qt5.9.0 beta3 (webinstaller), qt5.9 (without debug flags)

      I would love if this could be fixed by qt5.9, but I'm not sure how reasonable that is.

      Please let me know if I missed anything, if you cannot reproduce, or if you need any extra information! =)

      I will be upating this ticket with more information as I get it. I would be happy to spend some time trying to fix this, if I can understand the codebase well enough.

      Attachments

        1. browsermainwindow.cpp.patch
          0.4 kB
        2. web_contents_adapter.cpp.patch
          0.5 kB
        3. main.cpp
          2 kB

        Activity

          People

            alexandru.croitor Alexandru Croitor
            jgkamat Jay Kamat
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: