新建一个MFC Dialog工程,然后仿照CefSimple模仿实现自己的一个基于MFC窗口的Demo(具体代码稍后上),注意我仅仅只配置了所需要依赖的lib,并没有把CefSample的配置一起Copy,所以才导致后面的白屏,浪费了我一天时间。
坑一:CefInitialize崩溃
也许这个坑很多网友都遇到过,所以寻找度娘的时候问题很快就解决了,就是exe运行环境缺少必须要的资源包(不仅仅dll,所以图方便我们直接从CefSimple环境拷贝出来)。

坑二:Cef白屏
当出现白屏的时候我第一反应就是代码有bug,于是我从MFC工程切换到win32工程,从子窗口切换到Popup,各种尝试都不行,最后我把CefSimple整个工程拷贝过来,然后按照我的配置修改编译依旧白屏,此刻问题基本确定:工程配置不对。但是工程配置有什么不对呢?只能一点点的比较,终于在最后发现:后期生成事件没有配置。命令如下:

setlocal
mt.exe -nologo -manifest "H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/tests/cefsimple/cefsimple.exe.manifest" "H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/tests/cefsimple/compatibility.manifest" -outputresource:"E:/project/CefDemo/x64/Debug/cefsimple.exe";#1
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Debug/chrome_elf.dll E:/project/CefDemo/x64/Debug/chrome_elf.dll
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Debug/d3dcompiler_43.dll E:/project/CefDemo/x64/Debug/d3dcompiler_43.dll
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Debug/d3dcompiler_47.dll E:/project/CefDemo/x64/Debug/d3dcompiler_47.dll
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Debug/libcef.dll E:/project/CefDemo/x64/Debug/libcef.dll
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Debug/libEGL.dll E:/project/CefDemo/x64/Debug/libEGL.dll
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Debug/libGLESv2.dll E:/project/CefDemo/x64/Debug/libGLESv2.dll
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Debug/natives_blob.bin E:/project/CefDemo/x64/Debug/natives_blob.bin
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Debug/snapshot_blob.bin E:/project/CefDemo/x64/Debug/snapshot_blob.bin
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Debug/v8_context_snapshot.bin E:/project/CefDemo/x64/Debug/v8_context_snapshot.bin
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_directory H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Debug/swiftshader E:/project/CefDemo/x64/Debug/swiftshader
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Resources/cef.pak E:/project/CefDemo/x64/Debug/cef.pak
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Resources/cef_100_percent.pak E:/project/CefDemo/x64/Debug/cef_100_percent.pak
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Resources/cef_200_percent.pak E:/project/CefDemo/x64/Debug/cef_200_percent.pak
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Resources/cef_extensions.pak E:/project/CefDemo/x64/Debug/cef_extensions.pak
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Resources/devtools_resources.pak E:/project/CefDemo/x64/Debug/devtools_resources.pak
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_if_different H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Resources/icudtl.dat E:/project/CefDemo/x64/Debug/icudtl.dat
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
"D:\Program Files\CMake\bin\cmake.exe" -E copy_directory H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/Resources/locales E:/project/CefDemo/x64/Debug/locales
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd

上面命令主要实现两个功能:
1.将manifest 文件嵌入到exe内部。
2.将所依赖的文件copy到运行环境(所以如果配置了这个生成后事件,那么问题一就不需要手动拷贝依赖项了)。

manifest 文件学习参考:

  1. 什么是vs 程序的manifest文件
  2. exe或者dll 嵌入manifest文件方法
  3. VS2008 manifest文件简单应用

所以白屏的根本原因是缺少manifest文件,导致运行的时候出问题。
解决方法两种:

  1. 把上面的代码完整Copy到生成后事件里面去【记得修改自己的工程目录
  2. 如果之前已经把必要的文件和资源Copy到了运行环境,那么我们只需要Copy如下一段代码就OK啦(功能就是把manifest文件嵌入exe内部)【记得修改自己的工程目录】:
setlocal
mt.exe -nologo -manifest "H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/tests/cefsimple/cefsimple.exe.manifest" "H:/cef/cef_binary_3.3538.1852.gcb937fc_windows64/tests/cefsimple/compatibility.manifest" -outputresource:"E:/project/CefDemo/x64/Debug/cefsimple.exe";#1
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd

下一章节将描述如何把Cef作为一个子窗口集成到MFC工程和win32工程。

CefInitialize崩溃 Cef白屏相关推荐

  1. CEF 破解内存超过1G 崩溃白屏现象

    目录 1.CEF内存过大 白屏现象 2.解决方法: 1)无效方法 2)有效方法 3.内存疯涨的测试网址: 1.CEF内存过大 白屏现

  2. 传奇霸业微端登陆服务器无响应,传奇霸业微端和浏览器崩溃白屏修复教程

    传奇霸业WIN10系统微端和浏览器崩溃白屏修复教程,最近有玩家在用win10系统的电脑进行游戏时,微端和浏览器登录都出现了崩溃白屏的现象,那么这个问题怎么解决呢,下面小编就来教教大家. 如果你的电脑系 ...

  3. xmind白屏崩溃文件没有保存怎么办 怎么找回xmind未保存的文件

    xmind白屏或者崩溃,但是文件没有保存怎么办,该如何找回未保存的文件,用如下方法即可找回未保存的文件: 1.关闭xmind,重新打开xmind应用,左上角找到文件->文件缓存,点进去:(反正找 ...

  4. CEF Debug模式运行打开网页白屏

    问题描述: Demo在Debug模式运行后会出现白屏, 网上有解决方法:https://www.cnblogs.com/lvdongjie/p/13226022.html,虽然不能解决问题,但是对分析 ...

  5. 白屏优化_今日头条品质优化 图文详情页秒开实践

    背景 作为一个内容类应用,看新闻读资讯一直是头条用户的核心需求,页面的打开速度直接关系到用户使用头条的核心体验,在头条中,为了更多的承载足够丰富的样式和逻辑下保持多端体验的统一,详情页的内容我们是通过 ...

  6. 启动白屏处理_App启动优化一顿操作猛如虎

    前言 本次主要内容包括: 针对App启动优化我们做了哪些工作? 1.App启动优化方向:视觉体验优化 2.App启动优化方向:代码逻辑优化 一.App启动优化方向:视觉体验优化 App启动时白屏问题 ...

  7. 两个苹果手机怎么定位_苹果6手机一直闪白屏怎么办?苹果6手机一直闪白屏怎么办?...

    苹果6手机一直闪白屏怎么办?苹果6手机一直闪白屏怎么办? 果粉看到的白屏通常情况就是开关机时候会遇到,手机出现白屏肯定手机软件或者硬件出现故障,.后台运行太多.系统崩溃等故障,硬件那部分出现问题就需要 ...

  8. android fragment 白屏,当应用Crash后fragment出现白屏

    前段时间,发现一个问题,就是当应用发生Crash后,fragment莫名其妙的出现了白屏,经检查发现,其实并不是fragment没有加载而是空指针导致了数据无法加载所以产生了白屏现象.这是一个什么空指 ...

  9. 服务器显示屏出现白屏,远程服务器时出现白屏怎么解决

    远程服务器时出现白屏怎么解决 内容精选 换一换 远程登录裸金属服务器后,控制台出现如下异常现象:使用vim编辑退出后,可编辑区域剩下半个屏幕.输入字符长度超过80个时,当前行被覆盖.使用vim等文本编 ...

最新文章

  1. 聊聊三维重建-双目立体视觉原理
  2. R语言ggplot2可视化:ggplot2中使用element_text函数设置轴标签文本粗体字体(bold text,只设置x轴的标签文本使用粗体字体)
  3. CString初始化时提示字符串太大
  4. matlab循环矩阵
  5. 激光标记舱口轮廓生成_宣城国产圆管激光切割机-利晟激光
  6. android SQLite查询并显示用户输入的选择信息
  7. Java tree set_Java TreeSet tailSet()方法
  8. 基于任务编程_如何理解任何编程任务
  9. 塞尔达传说雷电大剑位置_《塞尔达传说:荒野之息》全收集——双手武器(1)...
  10. Silverlight学习之——我的看法
  11. E. Sergey and Subway
  12. mysql数据库简单指令_Mysql数据库一些简单命令
  13. [2018.03.14 T1] 矩阵(matrix)
  14. java 直方图_Java直方图
  15. kali linux系统下安装 VMware Tools
  16. 计算机音乐作曲专业,计算机音乐创作专业组
  17. p值 统计学意义_什么是统计意义? P值定义以及如何计算
  18. 麦克阿瑟天才奖得主解码计算机视觉“原罪”:AI 如何认识人类世界
  19. 7-2 后序+中序序列构造二叉树
  20. 华为云服务器(Centos7)安装与卸载mysql8

热门文章

  1. 1000:Calculate A + B
  2. 通过javax.mail发送邮件(示例gmail、qq)
  3. 「ICPC World Finals 2019」何以伊名始(广义后缀自动机)
  4. EasyPlayerPro安卓流媒体播放器实现Android H.265硬解码流程
  5. Mediaplay:Android后台同时播放多个音频文件第一弹:读取并播放音频文件
  6. 人的记忆组成图(原创整理,转载请注明)
  7. QT学习之QMainWindow详解
  8. BBS论坛项目相关-4:发帖模块
  9. 20135327郭皓--读书笔记六
  10. Python 运算符与数据类型