Closed Bug 1342850 Opened 7 years ago Closed 5 years ago

WebExtensions native messaging: Firefox busy loop when native host app is terminated

Categories

(WebExtensions :: General, defect, P5)

51 Branch
defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: jarkko.palviainen, Unassigned)

Details

(Whiteboard: investigating, triaged)

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36

Steps to reproduce:

As a developer I want to use native messaging in WebExtensions:
- Download Firefox 51 from official Mozilla in Debian 8.7 
- Clone the repo containing https://github.com/mdn/webextensions-examples/tree/master/native-messaging
- Copy native host manifest to ~/.mozilla/native-messaging-hosts/ping_pong.json and set the 'path' object pointing to ping_pong.py 
- Load the extension in Firefox add-on debug mode from the unpacked directory
- Open Browser console (ctrl-shift-J)
- Click the "native messaging example" icon in toolbar
- Observe "ping" and "pong" messages in browser console
- Enter "about:addons" to address bar
- Click 'Disable' for the native messaging example




Actual results:

- Open system monitor tool (e.g. htop) and see 3 firefox threads/processes with high CPU load. 

The problem stops only by forcefully stopping firefox.


Expected results:

When disabling the add-on, firefox should idle and no busy threads should happen.
Further details: I have tested this with other distros, Ubuntu 16.04.2 and Arch Linux which do not have the issue. This problem might be more related to the distro runtime. 

Te backtrace below from one of the busy processes hints that the message loop keeps getting the same event again without cleaning up properly when the native app is terminated. Possibly, the event is just the
closed fd from the app's stdout:

(gdb) bt
#0  0x00007f21ee6ceaed in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007f21e33b5f1f in PollWrapper(_GPollFD*, unsigned int, int) () from /home/palvja/temp/firefox-54.0a1/libxul.so
#2  0x00007f21e9144ee4 in g_main_context_poll (priority=2147483647, n_fds=5, fds=0x7f21bf89e730, timeout=-1,
    context=0x7f21ee371cc0) at /build/glib2.0-y6934K/glib2.0-2.42.1/./glib/gmain.c:4076
#3  g_main_context_iterate (context=context at entry=0x7f21ee371cc0, block=block at entry=1, dispatch=dispatch at entry=1,
    self=<optimized out>) at /build/glib2.0-y6934K/glib2.0-2.42.1/./glib/gmain.c:3776
#4  0x00007f21e9144ffc in g_main_context_iteration (context=0x7f21ee371cc0, may_block=1)
    at /build/glib2.0-y6934K/glib2.0-2.42.1/./glib/gmain.c:3842
#5  0x00007f21e33b5edf in nsAppShell::ProcessNextNativeEvent(bool) () from /home/palvja/temp/firefox-54.0a1/libxul.so
#6  0x00007f21e33b3d7e in nsBaseAppShell::OnProcessNextEvent(nsIThreadInternal*, bool) ()
   from /home/palvja/temp/firefox-54.0a1/libxul.so
#7  0x00007f21e3146422 in nsThread::ProcessNextEvent(bool, bool*) () from /home/palvja/temp/firefox-54.0a1/libxul.so
#8  0x00007f21e31462cc in NS_ProcessNextEvent(nsIThread*, bool) () from /home/palvja/temp/firefox-54.0a1/libxul.so
#9  0x00007f21e319a7cc in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) ()
   from /home/palvja/temp/firefox-54.0a1/libxul.so
#10 0x00007f21e3a45b67 in MessageLoop::Run() () from /home/palvja/temp/firefox-54.0a1/libxul.so
#11 0x00007f21e3bfbc8e in nsBaseAppShell::Run() () from /home/palvja/temp/firefox-54.0a1/libxul.so
#12 0x00007f21e3cf9233 in nsAppStartup::Run() () from /home/palvja/temp/firefox-54.0a1/libxul.so
#13 0x00007f21e3d13921 in XREMain::XRE_mainRun() () from /home/palvja/temp/firefox-54.0a1/libxul.so
#14 0x00007f21e3d10dd5 in XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) ()
   from /home/palvja/temp/firefox-54.0a1/libxul.so
#15 0x00007f21e3d10a11 in XRE_main(int, char**, mozilla::BootstrapConfig const&) ()
   from /home/palvja/temp/firefox-54.0a1/libxul.so
#16 0x000000000041305a in do_main(int, char**, char**) ()
#17 0x000000000040f224 in main ()

The issue is also reproducible with Debian backports (https://mozilla.debian.net/).
Component: Untriaged → WebExtensions: Untriaged
Product: Firefox → Toolkit
Assignee: nobody → kmaglione+bmo
Whiteboard: investigating
Priority: -- → P5
Whiteboard: investigating → investigating, triaged
Assignee: kmaglione+bmo → nobody
Users of GNOME Shell integration [1] browser extension confirm that HTitle addon [2] and GNOME Theme Tweak [3] causes same issue when used with WebExtensions native messaging.

[1] https://addons.mozilla.org/addon/gnome-shell-integration/
[2] https://addons.mozilla.org/addon/htitle/
[3] https://addons.mozilla.org/addon/adwaita/
Attached file crash_report.txt
Crash report from another GNOME Shell integration user
Product: Toolkit → WebExtensions
Bulk move of bugs per https://bugzilla.mozilla.org/show_bug.cgi?id=1483958
Component: Untriaged → General

The crash signature in comment 4 matches bug 1443544, and it's possibly unrelated to this bug. I cannot tell from the report, but in a different bug the same person mentioned that they're using Gentoo, which is different from Debian.

Jarkko, Is this issue still reproducible on the latest version of Firefox? If so, please state the exact versions, and how we can create your environment (e.g. in a virtual machine).

Flags: needinfo?(jarkko.palviainen)

Closing.for lack of actionable information.

If you're encountering this bug, and have information to share, please add a comment.

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Flags: needinfo?(jarkko.palviainen)
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: