Skip to content

Commit 2aff728

Browse files
committed
update documentation with detailed list of features and example of issues it can help to spot.
1 parent 9dbfbbc commit 2aff728

File tree

3 files changed

+82
-29
lines changed

3 files changed

+82
-29
lines changed

README.md

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,82 @@
1-
# <img src="./public/img/icon.svg" width="32"/> Browser API Monitor
1+
# <img src="./public/img/icon.svg" width="32"/> API Monitor - Chrome Developer Tools extension
22

33
- Available in Chrome Web Store as [API Monitor](https://chromewebstore.google.com/detail/api-monitor/bghmfoakiidiedpheejcjhciekobjcjp)
44

5-
If you're web developer and want to assess implementation correctness - this tool adds additional panel to the browser’s DevTool that enables to see scheduled timeouts and active intervals, as well as to review and navigate to initiators of: eval, setTimeout, setInterval, requestAnimationFrame, requestIdleCallback and their terminator functions.
5+
Chrome Developer Tools `API 🔎` panel tries to gather every bit of useful information from the usage of certain native functions that are prone to human errors, or are difficult to spot intuitively.
66

7-
#### Allows:
7+
#### Motivation
88

9-
- to measure callback execution self-time.
10-
- to see `requestAnimationFrame` callback request frame rate.
11-
- visit every function in the call stack (if available), bypass or pause while debugging.
12-
- detect `eval` function usage, see its argument and return value, same for `setTimeout` and `setInterval` when called with a string instead of a function.
13-
- for every mounted video or audio media element's to see it’s state and properties.
9+
To assess Web Application implementation correctness and expedite issues discovery. [See examples](./doc/issues.log.md).
1410

15-
#### Helps to spot:
11+
#### Functionality
12+
13+
- Gather callstack that is used to call every wrapped function:
14+
- **short** - just the nearest initiator.
15+
- **full** - from the root to the nearest initiator (from left to right).
1616

17-
- incorrect timeout delay.
18-
- bad handler for terminator function.
19-
- terminating non-existing or elapsed timeout.
17+
- Aggregate information about currently scheduled timeouts and running active intervals.
2018

21-
#### Motivation:
19+
- Gather details about which terminators are cancelling certain scheduled setters.
2220

23-
- To expedite issues discovery.
21+
- Allow to initiate a debugging session by redirecting the code flow to a `debugger` breakpoint right before the callback invocation.
22+
- Hit <kbd>F11</kbd> (step inside) **twice** in order to progress into the callback itself.
2423

25-
#### Wrapped native functions:
24+
- Allow to bypass (skip) setter's callback, or terminator invocation function.
2625

27-
- eval (by default off)
28-
- setTimeout
29-
- clearTimeout
30-
- setInterval
31-
- clearInterval
32-
- requestAnimationFrame
33-
- cancelAnimationFrame
34-
- requestIdleCallback
35-
- cancelIdleCallback
26+
- Detect anomalies in passed arguments such as:
27+
- Passing incorrect timeout delay to `setTimeout`, `setInterval`, `requestIdleCallback`.
28+
- Correct one is `undefined` or a number that is greater or equal to `0`.
29+
- Invoking terminator function with handler that is non-positive integer, or of non-existent or already elapsed setter.
3630

37-
> [!NOTE]
38-
> While measuring performance of your code – consider disabling this extension as it may affect the results.
31+
- Measure callback's execution self-time.
32+
- Warn if it exceeds 4/5 (13.33ms) of 60 FPS hardcoded frame-rate (16.66ms).
33+
- currently, there is no API to detect monitor refresh-rate at runtime due to browser security and privacy restrictions, hence hardcoded to 60 FPS.
34+
35+
- Count `requestAnimationFrame` calls per second (CPS).
36+
- If requested recursively - it reflects animation FPS.
37+
38+
- Detect `eval` function usage in runtime, as well as `setTimeout` and `setInterval` when called with a `string` callback instead of a `function`.
39+
40+
- Scan DOM each second for mounted `video` or `audio` media elements.
41+
- Present control panel with basic media functions.
42+
- Show media events and number of times they have been fired.
43+
- Show current state of properties.
44+
- Allow to toggle the state of changeable boolean properties e.g. `controls`, `preservesPitch`...
45+
46+
- Prevent the system from going to Sleep state due to user inactivity for a better observational experience.
47+
- By default `off`
3948

4049
<details>
41-
<summary> <strong>Example</strong> </summary>
50+
<summary> <strong>Wrapped native functions</strong> </summary>
51+
52+
- `eval`
53+
- by default `off`, cause the fact of wrapping it, excludes the access to local scope variables from the eval script, and that, as a result, may brake the application if it does need it.
54+
- `setTimeout`
55+
- `clearTimeout`
56+
- `setInterval`
57+
- `clearInterval`
58+
- `requestAnimationFrame`
59+
- `cancelAnimationFrame`
60+
- `requestIdleCallback`
61+
- `cancelIdleCallback`
62+
63+
</details>
64+
<details>
65+
<summary> <strong>Screenshots</strong> </summary>
4266

4367
![screenshot](./doc/screenshot-02.png)
4468
![screenshot](./doc/screenshot-04.png)
4569

4670
</details>
4771

72+
> [!NOTE]
73+
> While measuring performance of your code – consider disabling this extension as it may affect the results.
74+
4875
### Build requirements
4976

5077
- OS: Linux
5178
- Node: 22.14.0 (LTS)
52-
- [Deno](https://docs.deno.com/runtime/getting_started/installation/) 2.2.12
79+
- [Deno](https://docs.deno.com/runtime/getting_started/installation/) 2.3.5
5380

5481
### Build instructions
5582

doc/issues.log.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
> [!NOTE]
2+
> The content provided is for educational and informational purpose only. Websites, dates, names are not mentioned on purpose.
3+
4+
### Issues, that could have been spotted during the development
5+
6+
- A ~10ms delay interval, from an old third-party library, constantly consuming approximately 10% of CPU solely to check if the window was resized.
7+
8+
- A bundled dependency library that utilizes the `eval` function, thereby preventing the removal of `unsafe-eval` from the `Content-Security-Policy` header.
9+
10+
- Code that uses `eval` with modern syntax to check if it's supported by browser (not throws exception).
11+
12+
- Dependency package that was bundled with webpack config's [devtool: 'eval'](https://webpack.js.org/configuration/devtool/) in production mode.
13+
14+
- A substantial number of hidden video elements in DOM stopped working, after Chrome unexpectedly limited them to 100 per domain (later the limit was lifted to 1000).
15+
16+
- Redundant duplicate `video` element, hidden under the actual video on a landing-page.
17+
18+
- `setTimeout` used to animate instead of `requestAnimationFrame`.
19+
20+
- `setTimeout` with dynamically computed delay value ends to be called with `NaN`.
21+
22+
- Hidden UI feature runs its logic in the background.
23+
24+
- Indirectly, discovered from the bursts of short timeouts, fired in loop, from ResizeObserver of an invisible feature that appears to be for a power user only (or partially deprecated).
25+
26+
- Animation still runs (plus network requests) in the background after a "paywall" fullscreen popup. Despite claiming "it's to conserve data bandwidth". CPU usage doesn't drop to 0%.

src/view/menu/TogglePanels.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595

9696
<tr class="menu-item -dash-top">
9797
<td class="-left">
98-
Prevent system from going to Sleep state due to user inactivity
98+
Prevent the system from going to Sleep state due to user inactivity
9999
</td>
100100
<td class="-right">
101101
<button

0 commit comments

Comments
 (0)