question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How to connect Lighthouse CLI to Android's app webview

See original GitHub issue

I know how to connect to Google Chrome on Android (by forwarding tcp:9222 localabstract:chrome_devtools_remote), but I can’t find how to run a lighthouse test for a debuggable webview in an app. Webview is visible in chrome://inspect and I can run an audit from there but I need to pass custom config to the LS test.

Passing a config file through desktop Chrome would be also good enough for my use case but automating it with CLI would be even better.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
patrickhulcecommented, Aug 6, 2021

Could you please share how does Google Chrome connects to the app’s webview when it’s not possible with CLI yet?

The DevTools integration is built specifically to keep the existing page intact. It does not use the same target creation path that the node/CLI uses.

And is there a way to use special config file with Chrome’s Lighthouse audit?

Not without a lot of work 😃 You could use a custom-devtools-frontend and modify the config used by Lighthouse, but it’d probably be easier to just redeploy the page in a way that’s accessible from proper Android Chrome 😅

0reactions
patrickhulcecommented, Aug 10, 2021

Can you share more about that topic or point me to a place where I could learn it myself?

DevTools reimplements its own custom connection class that does not create new targets like the node/CLI path does.

This is the bit of code used by node/CLI that creates a new target to evaluate when lighthouse connects to Chrome.

https://github.com/GoogleChrome/lighthouse/blob/800ffd6da37e1be6712b04906d9abc701ff49fb6/lighthouse-core/gather/connections/cri.js#L36-L53

You would need to implement your own connection that skips this step in node.

DevTools basically needs to communicate in a way that should be reproducible using CLI Tools - a combination of adb and lighthouse probably?

As seen above, it’s not the communication method that’s the problem, it’s the fact that new targets are created.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Q] Can Lighthouse be used with Android WebView-based ...
I have an app (browser) based on Android WebView and i'd like to audit it with Lighthouse. I'm able to connect to Chrome...
Read more >
WebView - The correct way to use credentials - Stack Overflow
I am looking for a way to autofill the password. How can I solve it? My application's code is like this: package com.example.tehem.webviewapp;...
Read more >
Lighthouse: Optimize website speed - Chrome Developers
Press Command+Option+J (Mac) Control+Shift+J (Windows, Linux, ChromeOS). Chrome DevTools opens up alongside the demo. DevTools and the demo.
Read more >
Using Google Lighthouse to audit your web application
We will look at how you can use Google Lighthouse to effectively assess the performance of your web application and deliver a superior...
Read more >
WEBVIEW no longer work or suported. Need REST code.
I need REST code to replace the below WEBVIEW code to execute my web site. using Android.App; using Android.OS; using Android.Support.V7.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found