sailfishos / sailfish-browser

Sailfish Browser
https://github.com/sailfishos/sailfish-browser/wiki/Sailfish-Browser-wiki
Mozilla Public License 2.0
307 stars 87 forks source link

Fix hang when calling window.setBrowserCover() #1051

Open llewelld opened 10 months ago

llewelld commented 10 months ago

The call to window.setBrowserCover(webView.tabModel) in BrowserPage.qml causes the user interface to hang. To reproduce:

  1. Run the browser.
  2. Select the "Tab" icon on the far left hand side of the toolbar.
  3. Select the "Private" browser tab icon (Batman).
  4. Notice that the app hangs (but doesn't crash) as the page switches from persistent to private mode.

The same result can also be had by selecting "New private tab" from the main browser menu.

Commit 8a8c474abed7d95ac comments out the call to prevent this from happening, but a real fix is needed because this also has the side effect of preventing the cover image from rendering correctly.

git diff 51a72ef86825dcf0deca5ab3adc493247768eaee 8a8c474abed7d95ac9b32cbfa6fe90275cf97631
diff --git a/apps/browser/qml/pages/BrowserPage.qml b/apps/browser/qml/pages/BrowserPage.qml
index 4373eeef..e0fb48c5 100644
--- a/apps/browser/qml/pages/BrowserPage.qml
+++ b/apps/browser/qml/pages/BrowserPage.qml
@@ -225,7 +225,7 @@ Page {
             if (webView.tabModel.count === 0) {
                 webView.handleModelChanges(false)
             }
-            window.setBrowserCover(webView.tabModel)
+            //window.setBrowserCover(webView.tabModel)
         }
     }

The hang doesn't cause a crash, but it does cause a new EGL/Wayland thread to be created which could possible be the cause of the hang, see thread 70 below:

(gdb) c
Continuing.
[Parent 23887: Unnamed thread 7f88002670]: E/EmbedLite NON_IMPL:
    EmbedLite::virtual nsresult WebBrowserChrome::GetDimensions(uint32_t,
    int32_t*, int32_t*, int32_t*, int32_t*):542 GetView dimensitions
[New LWP 26091]
^C
Thread 1 "sailfish-browse" received signal SIGINT, Interrupt.
0x0000007fb7bcf718 in pthread_cond_wait () from /lib64/libpthread.so.0
(gdb) info thread
  Id   Target Id                   Frame 
* 1    LWP 23887 "sailfish-browse" 0x0000007fb7bcf718 in pthread_cond_wait ()
  2    LWP 24132 "QQmlThread"      0x0000007fb78a8740 in poll ()
  3    LWP 24133 "QDBusConnection" 0x0000007fb78a8740 in poll ()
  4    LWP 24134 "gmain"           0x0000007fb78a8740 in poll ()
  5    LWP 24135 "dconf worker"    0x0000007fb78a8740 in poll ()
  6    LWP 24137 "gdbus"           0x0000007fb78a8740 in poll ()
  7    LWP 24147 "QThread"         0x0000007fb78a8740 in poll ()
  8    LWP 24149 "GeckoWorkerThre" StringMatch (text=0x7f9df3bf40,
                                   pat=0x7f9e0400c0, start=start@entry=0)
                                   at js/src/builtin/String.cpp:1944
  10   LWP 24151 "IPC I/O Parent"  0x0000007fb78ade24 in syscall ()
  11   LWP 24152 "QSGRenderThread" 0x0000007fb7bcf718 in pthread_cond_wait ()
  12   LWP 24153 "Netlink Monitor" 0x0000007fb78a8740 in poll ()
  13   LWP 24154 "Socket Thread"   0x0000007fb78a8740 in poll ()
  15   LWP 24156 "TaskCon~read #0" 0x0000007fb7bcf718 in pthread_cond_wait ()
  16   LWP 24157 "TaskCon~read #1" 0x0000007fb7bcf718 in pthread_cond_wait ()
  17   LWP 24158 "TaskCon~read #2" 0x0000007fb7bcf718 in pthread_cond_wait ()
  18   LWP 24159 "TaskCon~read #3" 0x0000007fb7bcf718 in pthread_cond_wait ()
  19   LWP 24160 "TaskCon~read #4" 0x0000007fb7bcf718 in pthread_cond_wait ()
  20   LWP 24161 "TaskCon~read #5" 0x0000007fb7bcf718 in pthread_cond_wait ()
  21   LWP 24162 "TaskCon~read #6" 0x0000007fb7bcf718 in pthread_cond_wait ()
  22   LWP 24163 "TaskCon~read #7" 0x0000007fb7bcf718 in pthread_cond_wait ()
  24   LWP 24165 "Timer"           0x0000007fb7bcfb80 in pthread_cond_timedwait ()
  25   LWP 24167 "IPDL Background" 0x0000007fb7bcf718 in pthread_cond_wait ()
  26   LWP 24168 "Cache2 I/O"      0x0000007fb7bcf718 in pthread_cond_wait ()
  27   LWP 24169 "Cookie"          0x0000007fb7bcf718 in pthread_cond_wait ()
  32   LWP 24174 "Worker Launcher" 0x0000007fb7bcf718 in pthread_cond_wait ()
  33   LWP 24175 "QuotaManager IO" 0x0000007fb7bcf718 in pthread_cond_wait ()
  35   LWP 24177 "Softwar~cThread" 0x0000007fb7bcfb80 in pthread_cond_timedwait ()
  36   LWP 24178 "Compositor"      0x0000007fb7bcf718 in pthread_cond_wait ()
  37   LWP 24179 "ImageIO"         0x0000007fb7bcf718 in pthread_cond_wait ()
  38   LWP 24181 "DOM Worker"      0x0000007fb7bcf718 in pthread_cond_wait ()
  40   LWP 24183 "ImageBridgeChld" 0x0000007fb7bcf718 in pthread_cond_wait ()
  42   LWP 24185 "Permission"      0x0000007fb7bcf718 in pthread_cond_wait ()
  43   LWP 24186 "TRR Background"  0x0000007fb7bcf718 in pthread_cond_wait ()
  44   LWP 24187 "URL Classifier"  0x0000007fb7bcf718 in pthread_cond_wait ()
  48   LWP 24191 "ProxyResolution" 0x0000007fb7bcf718 in pthread_cond_wait ()
  49   LWP 24193 "mozStorage #1"   0x0000007fb7bcf718 in pthread_cond_wait ()
  50   LWP 24195 "HTML5 Parser"    0x0000007fb7bcf718 in pthread_cond_wait ()
  51   LWP 24196 "localStorage DB" 0x0000007fb7bcf718 in pthread_cond_wait ()
  53   LWP 24198 "StyleThread#0"   0x0000007fb7bcf718 in pthread_cond_wait ()
  54   LWP 24199 "StyleThread#1"   0x0000007fb7bcf718 in pthread_cond_wait ()
  55   LWP 24200 "StyleThread#2"   0x0000007fb7bcf718 in pthread_cond_wait ()
  56   LWP 24202 "StyleThread#3"   0x0000007fb7bcf718 in pthread_cond_wait ()
  57   LWP 24203 "StyleThread#4"   0x0000007fb7bcf718 in pthread_cond_wait ()
  58   LWP 24204 "StyleThread#5"   0x0000007fb7bcf718 in pthread_cond_wait ()
  65   LWP 24293 "mozStorage #2"   0x0000007fb7bcf718 in pthread_cond_wait ()
  66   LWP 24294 "mozStorage #3"   0x0000007fb7bcf718 in pthread_cond_wait ()
  69   LWP 24942 "Backgro~Pool #5" 0x0000007fb7bcfb80 in pthread_cond_timedwait ()
  70   LWP 26091 "QSGRenderThread" 0x0000007fb78a8740 in poll ()

Here's the backtrace for the tread:

Thread 70 (LWP 26091):
#0  0x0000007fb78a8740 in poll () from /lib64/libc.so.6
#1  0x0000007fafb38bfc in ?? () from /usr/lib64/libwayland-client.so.0
#2  0x0000007fafb3a258 in wl_display_dispatch_queue ()
    from /usr/lib64/libwayland-client.so.0
#3  0x0000007faf885204 in WaylandNativeWindow::readQueue(bool) ()
    from /usr/lib64/libhybris//eglplatform_wayland.so
#4  0x0000007faf8843ec in WaylandNativeWindow::finishSwap() ()
    from /usr/lib64/libhybris//eglplatform_wayland.so
#5  0x0000007fb73f9210 in _my_eglSwapBuffersWithDamageEXT ()
    from /usr/lib64/libEGL.so.1
#6  0x0000007fafa4e080 in ?? () from
    /usr/lib64/qt5/plugins/wayland-graphics-integration-client/libwayland-egl.so
#7  0x0000007fb88e5180 in QOpenGLContext::swapBuffers(QSurface*) ()
    from /usr/lib64/libQt5Gui.so.5
#8  0x0000007fb8e64c68 in ?? () from /usr/lib64/libQt5Quick.so.5
#9  0x0000007fb8e6ac10 in ?? () from /usr/lib64/libQt5Quick.so.5
#10 0x0000007fb7ce20e8 in ?? () from /usr/lib64/libQt5Core.so.5
#11 0x0000007fb7bc8a4c in ?? () from /lib64/libpthread.so.0
#12 0x0000007fb78b289c in ?? () from /lib64/libc.so.6

Note that this is a hang not a crash, so this backtrace is the rest of interrupting the program running.

llewelld commented 4 months ago

The changes to the offscreen rendering mean that this works correctly again, so I've reverted it with commit cfb68c46e9779dd25f8515078cd0b1587faf47bf.

I tested a few sites and checked their covers were rendered correctly, including sites that rendered WebGL content.

llewelld commented 4 months ago

Closing this was a mistake; it still needs fixing :(