Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Running Android automation permanently prevents Chrome Remote Debugging from working #26721

Closed
1 task done
Nantris opened this issue Aug 25, 2023 · 3 comments · Fixed by #26724
Closed
1 task done
Assignees
Labels

Comments

@Nantris
Copy link

Nantris commented Aug 25, 2023

System info

  • Playwright Version: 1.37.1
  • Operating System: Ubuntu 23.04
  • Browser: Chrome for Android
  • Other info: This occurs immediately, even if the automation fails with: "Please install Android driver apk using npx playwright install android"

Source code

  • I provided exact source code that allows reproducing the issue locally.

Config file

// playwright.config.ts
const config = {
  testMatch: /.*\.playwright-test\.js/,
  fullyParallel: true,
  use: {
    /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
    trace: 'on-first-retry',
  },
};
export default config;

Test file (self-contained)

const { _android: android } = require('playwright');

(async () => {
  const [device] = await android.devices();
  // await device.shell('am force-stop com.android.chrome'); // This line does not prevent the problem
  const context = await device.launchBrowser(); // THIS IS THE LINE THAT BREAKS THE EMULATOR FOR GOOD
})();

Steps

Warning: This process will effectively damage your emulator, rendering it unable to connect to Chrome Remote Debugging ever again.

  1. Create test file (eg android.js)
  2. Confirm emulator is connected to Chrome's remote debugging via chrome://inspect/#devices
  3. Run node android.js
  4. Almost instantly you will see the remote debugging disappear. Nothing can save this device once this occurs

Expected
Remote debugging is not disrupted, or at least, not permanently prevented

Actual
Remote debugging for the emulator will never work again, persisting through app data clearing, reboots, reinstalls, cold boots, most of the advice on StackOverflow, everything.

I confirmed this on two different emulators, one for API 31 and the other for API 33. Both suffer the same irreversible problem.

It presents as this device without anything under it, even though it had been connected to the device and showing its tabs immediately prior to running Playwright:
image

@pavelfeldman
Copy link
Member

Almost instantly you will see the remote debugging disappear. Nothing can save this device once this occurs

Could you explain what you mean by this? Playwright communicates to Android via ADB interface, independently from Chrome Devtools. When you say nothing can save it, do you mean that you can still start the browser, but chrome:inspect won't be able to see it?

As a guess, could you adb shell into that device and remove the file /data/local/tmp/chrome-command-line from it?

@Nantris
Copy link
Author

Nantris commented Aug 26, 2023

Thanks for your reply @pavelfeldman. Indeed you can still start and use Chrome on Android but nothing actually works.

Interestingly I realized that I don't even have Chrome Command Line enabled on this emulator currently (although in the past I did before rolling back my VM snapshot and the issue occurred just the same)

So that makes it especially curious that adb shell rm /data/local/tmp/chrome-command-line and then restarting Chrome for Android resolves the issue immediately.

Thanks very much for the tip @pavelfeldman and let me know if I can be any more help in resolving this issue for everyone.

@pavelfeldman
Copy link
Member

So that makes it especially curious that adb shell rm /data/local/tmp/chrome-command-line and then restarting Chrome for Android resolves the issue immediately.

Thanks for confirming it, I'll see what I can do to make sure we generate unix named pipe names that chrome picks up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants