web-ext icon indicating copy to clipboard operation
web-ext copied to clipboard

Ctrl + C does nothing when using firefox-android

Open SunriseFox opened this issue 6 years ago • 11 comments
trafficstars

Is this a feature request or a bug?

Bug.

What is the current behavior?

Ctrl + C does nothing.

What is the expected or desired behavior?

Should quit the program.

Version information (for bug reports)

  • Firefox version: -
  • Your OS and version: Windows
  • web-ext: 3.1.1

The very likely bad codes: src\extension-runners\firefox-android.js:537

    const handleCtrlC = (str, key) => {
      if (key.ctrl && key.name === 'c') {
        adbUtils.setUserAbortDiscovery(true);
      }
    };

    // TODO: use noInput property to decide if we should
    // disable direct keypress handling.
    if (isTTY(stdin)) {
      readline.emitKeypressEvents(stdin);
      setRawMode(stdin, true);

      stdin.on('keypress', handleCtrlC);
    }

#1569

SunriseFox avatar Sep 06 '19 06:09 SunriseFox

@SunriseFox we have a couple of questions to get a better picture of the issue (and how to reproduce it):

  • is the Firefox for android instance already running while you are pressing Ctrl-C?
  • which windows shell are you using? (e.g. cmd or powershell)
  • are you using any third party terminal application or the stardard one?

rpl avatar Sep 26 '19 14:09 rpl

  1. Yes.
  2. Powershell.
  3. The standard one.

SunriseFox avatar Sep 26 '19 14:09 SunriseFox

@SunriseFox Can I start work on this?

CS-Aditya-Rawat avatar Jan 11 '21 15:01 CS-Aditya-Rawat

Can I start work on this?

CS-Aditya-Rawat This bug requires some more investigation to determine more details about the underlying issue (and based on that the kind of changes we would prefer to fix it as its first step), and so if you are looking for a good-first-bug as a initial contribution then this one may not be a good "entry point" (at least not yet).

If a "good first bug" is what you are looking for, you may take a look to the ones not yet assigned to a contributor (or a PR recently open and linked to the issue) from this list:

  • https://addons-pm.herokuapp.com/contrib/good-first-bugs/?dir=desc&sort=updatedAt

Or one from the "contrib:welcome" list (but be aware that the older issues in the "contrib:welcome" list may not be relevant anymore but not closed yet, and they may require a bit more experience than the one marked as "good first bug"):

  • https://addons-pm.herokuapp.com/contrib/contrib-welcome/?dir=desc&sort=updatedAt

rpl avatar Jan 11 '21 17:01 rpl

Hello:

I've investigated this issue, and the problem arises in this finally block https://github.com/mozilla/web-ext/blob/7a1eba57e742aeef50b7342d47dca2ba0ac1838a/src/extension-runners/firefox-android.js#L598 with the whole relevant section being:

 try {
      // Got a debugger socket file to connect.
      this.selectedRDPSocketFile = (
        await adbUtils.discoverRDPUnixSocket(
          selectedAdbDevice, selectedFirefoxApk, {
            maxDiscoveryTime: unixSocketDiscoveryMaxTime,
            retryInterval: unixSocketDiscoveryRetryInterval,
          }
        )
      );
    } finally {
      if (isTTY(stdin)) {
        stdin.removeListener('keypress', handleCtrlC);
      }
    }

Removing the finally block (or the whole try...finally block leaving the try code for that matter) fixes the issue. Honestly, I don't understand why is that finally there to begin with as you are always removing the listener regardless, maybe it was meant to be a catch?

luskaner avatar Oct 05 '22 10:10 luskaner

@rpl can you assign me to this? This would be my first contribution but I think it's a pretty easy fix

luskaner avatar Oct 07 '22 10:10 luskaner

@luskaner feel free to submit a PR with "Fixes #1699" in the description, we'll assign you then

willdurand avatar Oct 07 '22 10:10 willdurand

@willdurand thanks will do

luskaner avatar Oct 07 '22 10:10 luskaner

Further investigating this happens in either of the following two conditions (in run):

  • Automatic reloading is disabled.
  • Waiting to launch the activity on Android. For example: this occurs undefinitely when my device when it is locked.

luskaner avatar Oct 07 '22 15:10 luskaner

@willdurand PR linked and ready ;)

luskaner avatar Oct 10 '22 18:10 luskaner

(I didn't forget about this PR, just have no time at the moment, sorry - I'll get back to it ASAP)

willdurand avatar Oct 17 '22 07:10 willdurand