Skip to the content.

Background

Solution: Forked a new devtools from 5.3.4 and adapted it for the complex legacy pages.

Features

image

image

Issue: Page Lag on Entry

Root Cause

Upon entering the page, thousands of vuex:mutation events are generated. Each vuex event serializes the store and sends it to backend.html.

image

Solution

Since we mostly check the latest state in vuex and rarely use the time-travel feature, we throttled vuex:mutation events as shown:

// devtools/packages/app-backend/src/vuex.js

+   const onMutation = debounce((...args) => this.onMutation(...args), 500); // Throttle onMutation as time-travel is not needed
    hook.on('vuex:mutation', onMutation);

Side Effect: A large number of vuex changes in a short time will record only 1-2 store snapshots.

Issue: Lag When Clicking Options

Root Cause

image

Solution

The router feature is rarely used, and the toggle is usually off. Ensure the toggle works as expected:

// packages/app-frontend/src/index.js

  bridge.once('ready', version => {
    store.commit('SHOW_MESSAGE', 'Ready. Detected Vue ' + version + '.')
    bridge.send('events:toggle-recording', store.state.events.enabled)
+   bridge.send('router:toggle-recording', store.state.router.enabled) // Properly initialize router toggle
    ...

Issue: Lag During Frequent Operations

Root Cause

A large number of triggered events cause the component module to invoke a massive number of flush updates in a short time.

Solution

Use throttling to reduce the frequency of flush updates:

// devtools/packages/app-backend/src/hook.js
    hook.on('flush', () => {
      if (hook.currentTab === 'components') {
-        flush()
+        debounceFlush()
      }
    })

Side Effect: After interactions, the submodules under Component (data, props, setup, etc.) will only update after 300ms.

Issue: Lag When Selecting Simple Components

Some simple components cause page lag and devtools to crash when selected.

Root Cause

Component instances from $refs are included in computed, leading to fetching data from other components’ instances.

image

A large computed property in levelList caused devtools to crash.

This was due to the use of @Ref syntax in the class, as shown:

@Ref(‘level-list’) levelList!: LevelList

The implementation of @Ref is as follows:

/**
 * decorator of a ref prop
 * @param refKey the ref key defined in template
 */
export function Ref(refKey) {
    return createDecorator(function (options, key) {
        options.computed = options.computed || {};
        options.computed[key] = {
            cache: false,
            get: function () {
                return this.$refs[refKey || key];
            },
        };
    });
}

Solution

When collecting data in devtools, remove properties in computed that have the same name as those in $refs:

// devtools/packages/app-backend/src/index.js

+ if (def.cache === false && !Reflect.hasOwnProperty(def, 'set')) {
+   if (Object.values(instance.$refs).find(comp => comp === instance[key])) {
+     continue
+   }
+ }

Issue: Devtools Becomes Unresponsive After Some Time

Root Cause

Different environments in the extension have varying communication mechanisms. For vue devtools, communication primarily involves backend.js and devtool.js:

Communication flow:

image

Connection characteristics:

Solution

Due to port disconnections, devtools becomes unresponsive. The solution involves:

Project Repository

https://github.com/kxxxlfe/devtools/releases

End