The main thread of the electron-vue process, CPU, is always high, and nothing is done on the interface.

The result seen by

top and the code of src/main/index.js are as follows. Where on earth is the CPU being consumed?

top - 15:03:51 up 9 days, 21:30,  6 users,  load average: 1.75, 1.62, 1.62
Threads:  19 total,   1 running,  18 sleeping,   0 stopped,   0 zombie
%Cpu(s): 54.5 us, 14.1 sy,  0.0 ni, 30.8 id,  0.0 wa,  0.0 hi,  0.5 si,  0.0 st
KiB Mem:   1873536 total,  1742908 used,   130628 free,     4536 buffers
KiB Swap:  1776636 total,   385540 used,  1391096 free.    69804 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
 2108 desktop+  20   0 2588888 1.401g  18244 R 99.9 78.4  14094:42 hsr-receiver
 2186 desktop+  20   0 2588888 1.401g  18244 S  3.0 78.4 387:44.34 hsr-receiver
 2187 desktop+  20   0 2588888 1.401g  18244 S  3.0 78.4 387:44.52 hsr-receiver
 2184 desktop+  20   0 2588888 1.401g  18244 S  2.7 78.4 387:43.88 hsr-receiver
 2185 desktop+  20   0 2588888 1.401g  18244 S  2.7 78.4 387:44.94 hsr-receiver
 2145 desktop+  20   0 2588888 1.401g  18244 S  1.0 78.4  91:38.58 hsr-receiver
11627 desktop+  20   0 2588888 1.401g  18244 S  0.3 78.4   0:02.21 WorkerPool/1162
20349 desktop+  20   0 2588888 1.401g  18244 S  0.3 78.4   0:00.73 WorkerPool/2034
24633 desktop+  20   0 2588888 1.401g  18244 S  0.3 78.4   0:00.01 WorkerPool/2463
 2115 desktop+  20   0 2588888 1.401g  18244 S  0.0 78.4   0:00.00 TaskSchedulerSe
 2116 desktop+  20   0 2588888 1.401g  18244 S  0.0 78.4   4:39.01 Chrome_ChildIOT
 2117 desktop+  20   0 2588888 1.401g  18244 S  0.0 78.4   0:23.91 GpuMemoryThread
 2126 desktop+  20   0 2588888 1.401g  18244 S  0.0 78.4  10:13.03 Compositor
 2127 desktop+  20   0 2588888 1.401g  18244 S  0.0 78.4   0:00.00 Renderer::FILE
 2128 desktop+  20   0 2588888 1.401g  18244 S  0.0 78.4   7:52.22 CompositorTileW
 2129 desktop+  30  10 2588888 1.401g  18244 S  0.0 78.4   0:00.00 CompositorTileW
14486 desktop+  20   0 2588888 1.401g  18244 S  0.0 78.4   0:01.30 WorkerPool/1448
20348 desktop+  20   0 2588888 1.401g  18244 S  0.0 78.4   0:00.98 WorkerPool/2034
23213 desktop+  20   0 2588888 1.401g  18244 S  0.0 78.4   0:00.32 WorkerPool/2321
import { app, BrowserWindow, globalShortcut, dialog, ipcMain} from "electron"
/**
 * Set `__static` path to static files in production
 * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
 */
if (process.env.NODE_ENV !== "development") {
  global.__static = require("path").join(__dirname, "/static").replace(/\\/g, "\\\\")
}

let mainWindow
const winURL = process.env.NODE_ENV === "development"
  ? `http://localhost:9080`
  : `file://${__dirname}/index.html`

function createWindow () {
  /**
   * Initial window options
   */
  mainWindow = new BrowserWindow({
    height: 1080,
    width: 1920,
    center: true,
    // show:false,
    useContentSize: true,
    fullscreen: true,//
    fullscreenable: false,//
    frame: false,//
    resizable: false, // 
    webPreferences: {webSecurity: false}, // 
    backgroundColor: "-sharp000000"
  })
  // mainWindow.on("resize", updateReply)
  mainWindow.loadURL(winURL)

  mainWindow.on("closed", () => {
    mainWindow = null
  })
  // mainWindow.once("ready-to-show", () => {
  //   mainWindow.show()
  // })
}
// function updateReply () {
//   const mangageWindowReply = document.getElementById("manage-window-reply")
//   const message = `Size: ${mainWindow.getSize()} Position: ${mainWindow.getPosition()}`

//   mangageWindowReply.innerText = message
// }
app.on("ready", createWindow)

//
app.on("ready", function() {
  globalShortcut.register("shift+enter", function () {
    // dialog.showMessageBox({
    //   type: "warning",
    //   message: "ubuntu",
    //   defaultId: 0,
    //   detail: "ctrl+j+m.",
    //   buttons: ["",""]
    // },function(response){
    //   if(response === 0){
    //     //
    //     mainWindow.close()
    //   }
    //   console.log(response)
    // })
    return
  });
});
//
ipcMain.on("min-window", () => {
  // mainWindow.close();
  app.quit();
});
//
ipcMain.on("focus-window", () => {
  if (mainWindow) {
    if (mainWindow.isMinimized()){
      mainWindow.restore();
    };
    mainWindow.focus();
  };
});

//
ipcMain.on("refresh-window", () => {
  mainWindow.hide();
  mainWindow.show();
});

app.on("will-quit", function () {
  globalShortcut.unregisterAll()
})
//
const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
  if (mainWindow) {
    if (mainWindow.isMinimized()){
      mainWindow.restore();
    };
    mainWindow.focus();
  };
});
if (shouldQuit) {
  app.quit();
};

app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    app.quit()
  }
})

app.on("activate", () => {
  if (mainWindow === null) {
    createWindow()
  }
})
Nov.25,2021

the new version of electron development environment has no problem after cpu100%, packaging

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b311cd-2bd82.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b311cd-2bd82.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?