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.

Performance Audit attribution from third-party wrapping

See original GitHub issue

Feature request summary

We are a third-party analytics provider that provides Real User Monitoring (RUM) and other features such as JavaScript Error Tracking through a JavaScript library our customers include on their pages called Boomerang.

Lately, we’ve had several customers raise support issues over their concerns that our JavaScript library is causing excessive JavaScript CPU usage, according to Lighthouse/PSI reports.

Here’s an example:

image

Upon investigation, we found that our Error Tracking plugin was causing Lighthouse to be confused about work being done in our customer’s app. The plugin wraps several high-level functions, and the callbacks of, setTimeout(), addEventListener() and others. It does this to ensure that the customer’s application can get detailed error messages (instead of the generic Script error. message) when errors are generated from scripts in other origins. More details are here, and other error tracking libraries do this wrapping as well.

Because Boomerang is wrapping the callbacks in setTimeout()/etc, any function in any file that calls setTimeout() will be attributed to Boomerang instead, because Boomerang’s wrapped callback is at the “bottom” of the stack. As you can imagine, this accounts for a lot of the JavaScript CPU time on many sites. The actual work done in the wrapped function is minimal (but non-zero), but the time of the entire callback is attributed to Boomerang instead of the “real” work being done. Our understanding is the “URL” of the JavaScript boot-up time /etc tables are based on the function/URL at the bottom of the stack.

If we were to disable Error Tracking and re-load the same page, we can see the real attribution moves a lot to the Page and other scripts (as well as Boomerang), but the “cost” of Boomerang has decreased from 770ms to 127ms:

image

We were hoping there would be a way to change it so these wrapping functions don’t get blamed for the entire callback cost. One idea would be to have a list of files or functions that could be excluded from “blame” if at the bottom of the stack, similar to library blackboxing.

We’re not sure if that’s feasible though:

  • We’d still want the non-wrapping code in Boomerang to be judged based on the work it does, of course.
  • We’d like for our customers’s Lighthouse/PSI runs to have this exclusion applied without them having to make any changes or configure any lists (can this be built-into Lighthouse?)
  • Each of our customers load our third-party library from distinct URLs

The only other alternates we’ve come up with is better education (explaining the issue to the customer, which we’re doing now), or disabling Boomerang’s wrapping if Lighthouse is detected (which we’d prefer to not do).

I have a repro page here, which merely does a setTimeout() that busy-loops for 2 seconds:

image

image

I’m willing to work on this change, if there’s agreement on a correct approach.

What is the motivation or use case for changing this?

To accurately reflect JavaScript CPU cost when third-party libraries are in the callstack.

How is this beneficial to Lighthouse?

More accurate JavaScript CPU attribution.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:8

github_iconTop GitHub Comments

1reaction
patrickhulcecommented, Feb 8, 2019

That is correct, #7059 should solve your customer-facing issue 👍

I think it just needs to be reviewed so no further action needed on your part!

0reactions
nicjansmacommented, Aug 31, 2020

@cheneytsai Yeah I certainly wouldn’t expect Boomerang to be anything more than ~200ms in most scenarios.

If you have the trace file, you could share it (or drop me an email nic at nicj dot net) and we can take a look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance Audit - IDI
Quality Statement for Performance Audit ISSAI Implementation Handbook Version 1 (8 June ... How do you consider audited entities or third party comments?...
Read more >
GAO-04-87G Audit Guide - Government Accountability Office
It is intended to provide practical guidance for consideration by internal and external auditors, investigators, and program management oversight personnel in.
Read more >
guide for audits of proprietary schools - Department of Education
September 2016. GUIDE FOR AUDITS OF PROPRIETARY SCHOOLS. AND FOR COMPLIANCE ATTESTATION. ENGAGEMENTS OF THIRD-PARTY SERVICERS.
Read more >
Best practices for using third-party embeds - web.dev
It is a good practice to periodically audit the performance impact of your embeds and third-party code because embed source code may change....
Read more >
A Food Producer's Guide to 3rd Party Audits - FDA Reader
A third party audits is typically required when the purchaser of a food product (or packaging) wants to confirm the quality and safety...
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