You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/10/19 10:39:52 UTC

[GitHub] [cordova-android] raphinesse opened a new issue #1098: Killing all adb processes messes with following calls to `adb devices`

raphinesse opened a new issue #1098:
URL: https://github.com/apache/cordova-android/issues/1098


   # Bug Report
   
   ## Problem
   
   In certain programs paths we spawn `killall adb` in an attempt to fix a supposedly invalid state of `adb`. For example: when `device.list` is run with the `lookHarder` option set to `true` and the initial `adb devices` run returns no devices, `device.list` will kill the adb server and try again.
   
   Unfortunately, that `killall adb` causes all `adb devices` calls in a certain time frame after it to list all emulators as `offline`. Since we filter out devices with state `offline`, calls to `emulator.list` within that time frame will have wrong results.
   
   Also, if I had an instance of `adb logcat` running, Cordova would kill that too I guess?
   
   ### What is expected to happen?
   With no devices connected and at least one running emulator:
   
   ```js
   emus1 = await emulator.list();
   devs = await device.list(true);
   emus2 = await emulator.list();
   
   expect(emus1).toEqual(emus2);
   ```
   
   
   ### What does actually happen?
   ```js
   emus1 = await emulator.list();
   devs = await device.list(true);
   emus2 = await emulator.list();
   
   expect(emus1.length).toBeGreaterThan(0);
   expect(emus2.length).toBe(0);
   ```
   
   ### Reproduction on the shell
   The JS code `await device.list(true); await emulator.list()` runs this sequence of commands:
   
   ```bash
   adb devices && killall adb && adb devices && adb devices
   ```
   
   On my machine the second and third call to `adb devices` lists all emulators as offline. The third one would be the one from `emulator.list`.
   
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   This behavior was introduced in https://github.com/apache/cordova-android/commit/66fa12a to fix [CB-8119](https://issues.apache.org/jira/browse/CB-8119).
   
   ## Solution
   The problem this `killall` is supposed to solve might not even exist anymore. I remember adb losing devices a few years back but it hasn't happened to me in a long time. It would be great to know if someone still encounters these problems today on a regular basis. If not, we could simply put an end to all that killing :wink: 
   
   If there is still a problem with adb stability that we need or want to solve in Cordova, we need to do better. A robust solution would be introducing a global mutex in our Adb module that is locked when running an adb command or restarting the adb server. After restarting the server we would probably have to introduce a delay of around 100 ms (on my machine) before unlocking that mutex.
   
   I really hope we can just drop that stuff...


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek edited a comment on issue #1098: Killing all adb processes messes with following calls to `adb devices`

Posted by GitBox <gi...@apache.org>.
breautek edited a comment on issue #1098:
URL: https://github.com/apache/cordova-android/issues/1098#issuecomment-713555174


   > I remember adb losing devices a few years back but it hasn't happened to me in a long time.
   
   This does happen to me time to time (not consistently), but in those cases, cordova will just end up firing up the emulator instead of trying to look for a device. This might be because I use the `cordova run android` command without specifying a target however.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #1098: Killing all adb processes messes with following calls to `adb devices`

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1098:
URL: https://github.com/apache/cordova-android/issues/1098#issuecomment-713555174


   > I remember adb losing devices a few years back but it hasn't happened to me in a long time.
   
   This does happen to me time to time (not consistently), but in those cases, cordova will just end up firing up the emulator instead of trying to look for a device. This might be because I use the `cordova run android` command without specifying however.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek edited a comment on issue #1098: Killing all adb processes messes with following calls to `adb devices`

Posted by GitBox <gi...@apache.org>.
breautek edited a comment on issue #1098:
URL: https://github.com/apache/cordova-android/issues/1098#issuecomment-713555174


   > This does happen to me time to time (not consistently), but in those cases, cordova will just end up firing up the emulator instead of trying to look for a device.
   
   Without target arguments, Cordova will only start an emulator if it does not find any running emulators or connected devices. The behavior you describe shows pretty neatly that the kill-fix we have right now fails to achieve its intended effect.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] raphinesse closed issue #1098: Killing all adb processes messes with following calls to `adb devices`

Posted by GitBox <gi...@apache.org>.
raphinesse closed issue #1098:
URL: https://github.com/apache/cordova-android/issues/1098


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org