|
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 |
2 | 2 |
|
3 | 3 | - Available in Chrome Web Store as [API Monitor](https://chromewebstore.google.com/detail/api-monitor/bghmfoakiidiedpheejcjhciekobjcjp)
|
4 | 4 |
|
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. |
6 | 6 |
|
7 |
| -#### Allows: |
| 7 | +#### Motivation |
8 | 8 |
|
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). |
14 | 10 |
|
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). |
16 | 16 |
|
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. |
20 | 18 |
|
21 |
| -#### Motivation: |
| 19 | +- Gather details about which terminators are cancelling certain scheduled setters. |
22 | 20 |
|
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. |
24 | 23 |
|
25 |
| -#### Wrapped native functions: |
| 24 | +- Allow to bypass (skip) setter's callback, or terminator invocation function. |
26 | 25 |
|
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. |
36 | 30 |
|
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` |
39 | 48 |
|
40 | 49 | <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> |
42 | 66 |
|
43 | 67 | 
|
44 | 68 | 
|
45 | 69 |
|
46 | 70 | </details>
|
47 | 71 |
|
| 72 | +> [!NOTE] |
| 73 | +> While measuring performance of your code – consider disabling this extension as it may affect the results. |
| 74 | +
|
48 | 75 | ### Build requirements
|
49 | 76 |
|
50 | 77 | - OS: Linux
|
51 | 78 | - 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 |
53 | 80 |
|
54 | 81 | ### Build instructions
|
55 | 82 |
|
|
0 commit comments