cefview / cocoacefview Goto Github PK
View Code? Open in Web Editor NEWA Cocoa View object encapsulated CEF view based on NSView
License: MIT License
A Cocoa View object encapsulated CEF view based on NSView
License: MIT License
当网页中有错误(比如网络请求错误或资源加载错误)启动时会报下面的错误:
CrBrowserMain (1): EXC_BAD_ACCESS (code=1, address=0x0)
求教如何避免?
生成的app文件巨大,debug 999M , release 729M
app里有3份Chromium Embedded Framework.framework
分别位于:
/CocoaCefViewDemo.app/Contents/Frameworks/CocoaCefView.framework/Resources/
/CocoaCefViewDemo.app/Contents/Frameworks/CocoaCefView.framework/Versions/A/
/CocoaCefViewDemo.app/Contents/Frameworks/CocoaCefView.framework/Versions/Current/Resources/
请问这要怎么解决?谢谢。
如何添加UserAgent到cefView?
RT
macOS 11.5.2
xcode 12.5.1
这个库还在维护么?刚才下载试了下,不能正常加载网页,一直在闪。
对于网页端开发网页的方式有两种,
1:window.open(“”)
2:window.location.href =“”
对于wkwebView可以通过两个代理方法来处理两种不同的方式。请问cefView如何区分这两种打开方式呢?
RT
如果想给 renderer 进程 js 环境注册 native 代码的话(比如 NSPasteboard
相关),需要自定义 RenderDelegate。
现在 CefView 中的 messge_router 和 invokeMethod 机制都只能是异步的。
我可以写在 CefViewCore 里面,但是感觉太侵入了。
这个error会打印一遍
2021-12-14 14:26:16.383360+0800 CefViewWing (GPU)[52431:20128290] [1214/142616.383192:ERROR:vt_video_encode_accelerator_mac.cc(537)] VTCompressionSessionCreate failed: -12903
[1214/142616.383192:ERROR:vt_video_encode_accelerator_mac.cc(537)] VTCompressionSessionCreate failed: -12903
下边的打印信息会不停的打印,请问是什么原因呢?
2021-12-14 14:27:24.400414+0800 CefViewWing (GPU)[52431:20128338] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x60000097c500> (Domain: kCFPreferencesAnyApplication, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): accessing preferences outside an application's container requires user-preference-read or file-read-data sandbox access
你好 tishion ,我想询问一个关于原版CEF调整大小的问题(非CocoaCefView)
以下是原版CEF的 cefclient 例子root_window_mac.mm 文件中 创建浏览器窗口方法
if (!is_popup_) {
// Create the browser window.
browser_window_->CreateBrowser(
CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(viewForCEF),
CefRect(0, 0, width, height), settings, nullptr,
root_window_.delegate_->GetRequestContext(&root_window_));
}
其中 CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(viewForCEF) ,这里的view本来是contentView , 我把它改成自己创建的一个NSView ,我想让网页随viewForCEF大小变化
viewForCEF = [[NSView alloc]initWithFrame:NSMakeRect(0, 0, width, height)];
[contentView addSubview:viewForCEF];
然后我实验创建了一个NSButton ,按这个按钮,运行:
-(void)buttonPressed {
NSLog(@"Button pressed!");
CGFloat w = window_.contentView.frame.size.width - 100;
CGFloat h = window_.contentView.frame.size.height;
[viewForCEF setFrame:NSMakeRect(0, 0,w,h)];
}
我发现这个方法是可行的,是我想要的效果,网页大小刚好比窗口大小100,完美
但是如果把调整viewForCEF大小的代码放进 NSWindowDelegate windowDidResize 里,就出问题了,网页大小不对,而且被clip掉了:
- (void)windowDidResize:(NSNotification *)notification{
CGFloat w = window_.contentView.frame.size.width - 100;
CGFloat h = window_.contentView.frame.size.height;
[viewForCEF setFrame:NSMakeRect(0, 0,w,h)];
}
我发现,如果上面的代码放在NSTimer里或用dispatch_after 或 performSelector 方法延迟0.5秒左右也可以完美调整网页大小(即网页大小为viewForCEF的大小),另外使用手动按钮运行调整大小代码也是一样的道理
- (void)windowDidResize:(NSNotification *)notification{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(buttonPressed) object:nil];
[self performSelector:@selector(buttonPressed) withObject:nil afterDelay:0.5];
}
所以我想请问,有什么方法可以立即调整viewForCEF的大小,且能够使网页大小和viewForCEF大小一致呢?
这是一个线程的问题,还是什么问题?
这问题我搜索了整个网络都没有答案,资料太少,我又菜
谢谢🙏
运行起来的cefView,每次加载url前总是会出现红色的背景。然后才会加载页面?这样的问题有遇到吗?如何解决?
请问大佬这是基于哪个版本的CEF ? 鼠标滚轮滚动网页没有平滑效果呢?
能不能用最新的CEF?
p.s. 真是佩服大佬这等神功,我看官方cefclient例子,都不知道从哪里下手加一个按钮,好不容易加了按钮,不知道怎么设置浏览器上下左右的边距...
请问作者,集成cocoaCefView到项目必须用xib形式添加吗?我用代码集成项目一直无法成功(我是将cocoaCefView添加再viewController上面)。还有个疑问就是,必须要修改main函数入口的CocoaCefApplication吗?如果看到信息麻烦及时回复([Nib Loading] Failed to connect (window) outlet from (CocoaCefApp) to (NSWindow): missing setter or instance variable)
ok,目前通过这个已经解决了(https://developer.apple.com/forums/thread/74868)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.