vite-plugin-electron icon indicating copy to clipboard operation
vite-plugin-electron copied to clipboard

使用了electron^34.0.1的项目,启动后控制台报错提示:ERROR:direct_composition_support.cc(1070)

Open aoqixie opened this issue 11 months ago • 2 comments

项目依赖如下:

"devDependencies": {
    "@vitejs/plugin-vue": "^5.0.4",
    "electron": "^34.0.1",
    "electron-builder": "^24.13.3",
    "typescript": "^5.4.2",
    "vite": "^5.1.5",
    "vite-plugin-electron": "^0.28.4",
    "vite-plugin-electron-renderer": "^0.14.5",
    "vue": "^3.4.21",
    "vue-tsc": "^2.0.6"
  }

npm run dev启动后,控制台报错如下:

[17580:0124/152351.117:ERROR:direct_composition_support.cc(1070)] QueryInterface to IDCompositionDevice4 failed: 不支持此接口 (0x80004002)

不过程序正常启动,好像也没什么问题。在找原因的过程中,发现electron-vite-vue这个模板没有出现这个错误提示。查看package.json,发现依赖的electron是29.1.1,把electron的版本改成34.0.1后,也提示了这个错误。

我是一个初学者,不清楚这个错误是如何产生的,会造成什么影响,希望大佬能教教我

aoqixie avatar Jan 24 '25 07:01 aoqixie

这个错误多数发生在 Windows 系统上运行 Electron 应用 时,Electron 的 Chromium 渲染引擎在初始化图形设备时,试图调用 IDCompositionDevice4 接口,但当前系统或驱动不支持,导致失败。

// 禁用硬件加速,以避免此警告
app.disableHardwareAcceleration();
app.whenReady().then(()=>{
  // createWindow here
})

yanglee2421 avatar Apr 12 '25 03:04 yanglee2421

这样的确能解决问题,但是会对electron的动画效果带来不良影响。关闭时,一些css动态效果将不再平滑和流畅

MugeTong avatar Oct 11 '25 13:10 MugeTong