Closed Bug 1936952 Opened 1 year ago Closed 1 year ago

[Headless] nsColorPicker::Open crash under automation

Categories

(Firefox :: Headless, defect, P2)

Firefox 132
Desktop
Linux
defect
Points:
1

Tracking

()

RESOLVED FIXED
135 Branch
Tracking Status
firefox135 --- fixed

People

(Reporter: max, Assigned: whimboo)

Details

(Whiteboard: [webdriver:m14])

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

Steps to reproduce:

See https://github.com/microsoft/playwright/issues/33864

Actual results:

Crash

#0  0x000074d45ebdc7da in g_log_writer_default () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x000074d45a76e4c5 in glib_log_writer_func (flags=G_LOG_LEVEL_ERROR, fields=0x7ffdd3ff1b70, n_fields=6, user_data=0x0)
    at /home/pwuser/firefox/toolkit/xre/nsSigHandlers.cpp:210
#2  0x000074d45ebd4044 in g_log_structured_array () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x000074d45ebd42a8 in g_log_structured_standard () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x000074d45f06c25e in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#5  0x000074d45eb4fff9 in g_type_create_instance () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x000074d45eb35a64 in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x000074d45eb37016 in g_object_new_with_properties () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x000074d45eb37f71 in g_object_new () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x000074d45f17c708 in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#10 0x000074d45f17c9a3 in gtk_style_new () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#11 0x000074d45f182c61 in gtk_widget_get_default_style () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#12 0x000074d45f10cd62 in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#13 0x000074d45eb4ffbb in g_type_create_instance () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
--Type <RET> for more, q to quit, c to continue without paging--
#14 0x000074d45eb35a64 in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#15 0x000074d45eb37bc3 in g_object_new_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#16 0x000074d45eb37f4f in g_object_new () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0


#17 0x000074d45990cbc3 in nsColorPicker::Open (this=0x74d43a643880, aColorPickerShownCallback=<optimized out>)
    at /home/pwuser/firefox/widget/gtk/nsColorPicker.cpp:98
#18 0x000074d459156206 in mozilla::dom::ColorPickerParent::RecvOpen (this=0x74d43a445500)
    at /home/pwuser/firefox/dom/ipc/ColorPickerParent.cpp:69

#19 0x000074d45922496c in mozilla::dom::PColorPickerParent::OnMessageReceived (this=0x74d43a445500, msg__=<optimized out>)
    at /home/pwuser/firefox/obj-build-playwright/ipc/ipdl/PColorPickerParent.cpp:190
#20 0x000074d45928fd00 in mozilla::dom::PContentParent::OnMessageReceived (this=0x74d44ac0a000, msg__=...)
    at /home/pwuser/firefox/obj-build-playwright/ipc/ipdl/PContentParent.cpp:6464
#21 0x000074d45578882f in mozilla::ipc::MessageChannel::DispatchAsyncMessage (this=this@entry=0x74d44ac0a090, aProxy=0x74d4443343e0, aMsg=...)
    at /home/pwuser/firefox/ipc/glue/MessageChannel.cpp:1785
#22 0x000074d4557866b0 in mozilla::ipc::MessageChannel::DispatchMessage
    (this=this@entry=0x74d44ac0a090, aProxy=aProxy@entry=0x74d4443343e0, aMsg=...) at /home/pwuser/firefox/ipc/glue/MessageChannel.cpp:1712
#23 0x000074d455786f4e in mozilla::ipc::MessageChannel::RunMessage (this=0x74d44ac0a090, aProxy=0x74d4443343e0, aTask=...)
    at /home/pwuser/firefox/ipc/glue/MessageChannel.cpp:1503
#24 0x000074d455787a80 in mozilla::ipc::MessageChannel::MessageTask::Run (this=0x74d43b5beb30)
    at /home/pwuser/firefox/ipc/glue/MessageChannel.cpp:1603
#25 0x000074d454dd8708 in mozilla::RunnableTask::Run (this=0x74d43a445900) at /home/pwuser/firefox/xpcom/threads/TaskController.cpp:618
#26 0x000074d454dd1ed3 in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal (this=this@entry=0x74d460e36800, aProofOfLock=...)
    at /home/pwuser/firefox/xpcom/threads/TaskController.cpp:945
#27 0x000074d454dd0b78 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal (this=this@entry=0x74d460e36800, aProofOfLock=...)
    at /home/pwuser/firefox/xpcom/threads/TaskController.cpp:768
#28 0x000074d454dd0ff6 in mozilla::TaskController::ProcessPendingMTTask (this=0x74d460e36800, aMayWait=false)
    at /home/pwuser/firefox/xpcom/threads/TaskController.cpp:554
#29 0x000074d454ddbbd7 in mozilla::TaskController::TaskController()::$_0::operator()() const (this=<optimized out>)
    at /home/pwuser/firefox/xpcom/threads/TaskController.cpp:268
#30 mozilla::detail::RunnableFunction<mozilla::TaskController::TaskController()::$_0>::Run() (this=<optimized out>)
    at /home/pwuser/firefox/xpcom/threads/nsThreadUtils.h:548
#31 0x000074d454def1ad in nsThread::ProcessNextEvent (this=0x74d460e81580, aMayWait=false, aResult=0x7ffdd3ff43af)
    at /home/pwuser/firefox/xpcom/threads/nsThread.cpp:1155
#32 0x000074d454df5cf0 in NS_ProcessNextEvent (aThread=0x74d460f00020, aThread@entry=0x74d460e81580, aMayWait=false)
    at /home/pwuser/firefox/xpcom/threads/nsThreadUtils.cpp:480
#33 0x000074d45578c8e7 in mozilla::ipc::MessagePump::Run (this=0x74d460efc5c0, aDelegate=0x74d460e39200)
    at /home/pwuser/firefox/ipc/glue/MessagePump.cpp:85
#34 0x000074d4557106c2 in MessageLoop::RunHandler (this=0x74d460f00020) at /home/pwuser/firefox/ipc/chromium/src/base/message_loop.cc:363
#35 MessageLoop::Run (this=0x74d460f00020) at /home/pwuser/firefox/ipc/chromium/src/base/message_loop.cc:345
#36 0x000074d45984e829 in nsBaseAppShell::Run (this=0x74d450d85b00) at /home/pwuser/firefox/widget/nsBaseAppShell.cpp:148
#37 0x000074d4598fbdf9 in nsAppShell::Run (this=0x74d450d85b00) at /home/pwuser/firefox/widget/gtk/nsAppShell.cpp:469
#38 0x000074d45a645d55 in nsAppStartup::Run (this=0x74d450d82420) at /home/pwuser/firefox/toolkit/components/startup/nsAppStartup.cpp:295
#39 0x000074d45a761353 in XREMain::XRE_mainRun (this=this@entry=0x7ffdd3ff46c0) at /home/pwuser/firefox/toolkit/xre/nsAppRunner.cpp:5810
#40 0x000074d45a7628d0 in XREMain::XRE_main (this=this@entry=0x7ffdd3ff46c0, argc=argc@entry=7, argv=argv@entry=0x7ffdd3ff5a18, aConfig=...)
--Type <RET> for more, q to quit, c to continue without paging--
    at /home/pwuser/firefox/toolkit/xre/nsAppRunner.cpp:6039
#41 0x000074d45a7636e9 in XRE_main (argc=7, argv=0x7ffdd3ff5a18, aConfig=...) at /home/pwuser/firefox/toolkit/xre/nsAppRunner.cpp:6111
#42 0x0000619b21f555df in do_main (argc=7, argv=0x7ffdd3ff5a18, envp=0x7ffdd3ff5a58) at /home/pwuser/firefox/browser/app/nsBrowserApp.cpp:233
#43 main (argc=7, argv=0x7ffdd3ff5a18, envp=0x7ffdd3ff5a58) at /home/pwuser/firefox/browser/app/nsBrowserApp.cpp:470
(gdb) 

Expected results:

No crash.

This is similar to https://bugzilla.mozilla.org/show_bug.cgi?id=1927101 -

  • // Don't attempt to open a real file-picker in headless mode.
  • if (gfxPlatform::IsHeadless()) {
  • return NS_ERROR_NOT_AVAILABLE;
  • }

should be added.

Component: Untriaged → Headless
OS: Unspecified → Linux
Hardware: Unspecified → Desktop
diff --git a/widget/gtk/nsColorPicker.cpp b/widget/gtk/nsColorPicker.cpp
index 4719710d9ebb..3219a69c2caa 100644
--- a/widget/gtk/nsColorPicker.cpp
+++ b/widget/gtk/nsColorPicker.cpp
@@ -13,6 +13,7 @@
 #include "nsIWidget.h"
 #include "WidgetUtils.h"
 #include "nsPIDOMWindow.h"
+#include "gfxPlatform.h"
 
 using mozilla::dom::HTMLInputElement;
 
@@ -76,6 +77,10 @@ NS_IMETHODIMP nsColorPicker::Init(mozIDOMWindowProxy* aParent,
 
 NS_IMETHODIMP nsColorPicker::Open(
     nsIColorPickerShownCallback* aColorPickerShownCallback) {
+  // Don't attempt to open a real color-picker in headless mode.
+  if (gfxPlatform::IsHeadless()) {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
   auto maybeColor = HTMLInputElement::ParseSimpleColor(mInitialColor);
   if (maybeColor.isNothing()) {
     return NS_ERROR_FAILURE;

this makes it work for us - would appreciate a ton if you could create a patch with this.

This patch ensures that the GTK-based color picker does not
attempt to open when running in headless mode. It prevents
unnecessary errors when tests run without a display environment.

Assignee: nobody → hskupin
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Severity: -- → S3
Points: --- → 1
Priority: -- → P2
Whiteboard: [webdriver:m14]
Pushed by hskupin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ff653eecc235 fix(gtk): Prevent nsColorPicker from opening in headless mode. r=bytesized
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 135 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: