启动时,我在logcat中收到以下错误消息。
org.chromium.chrome E/chromium: [ERROR:devtools_http_handler.cc(249)] Cannot start http server for devtools. Stop devtools.
我正在运行Chromium内部版本65.0.3317.0。在早期版本的Chromium 54.0.2840.9上不会发生此错误,并且铬devtools可以正常工作。当我尝试使用devtools检查远程android设备时,将打开空白标签,错误为HTTP/1.1 404 Not Found
。
我还将在引发错误的文件中附加不同的内容。
Chromium 54-devtools_http_handler.cc
void StartServerOnHandlerThread(
base::WeakPtr<DevToolsHttpHandler> handler,
base::Thread* thread,
DevToolsHttpHandler::ServerSocketFactory* server_socket_factory,
const base::FilePath& output_directory,
const base::FilePath& frontend_dir,
bool bundles_resources) {
DCHECK(thread->task_runner()->BelongsToCurrentThread());
ServerWrapper* server_wrapper = nullptr;
std::unique_ptr<net::ServerSocket> server_socket =
server_socket_factory->CreateForHttpServer();
std::unique_ptr<net::IPEndPoint> ip_address(new net::IPEndPoint);
if (server_socket) {
server_wrapper = new ServerWrapper(handler, std::move(server_socket),
frontend_dir, bundles_resources);
if (!output_directory.empty())
server_wrapper->WriteActivePortToUserProfile(output_directory);
if (server_wrapper->GetLocalAddress(ip_address.get()) != net::OK)
ip_address.reset();
} else {
ip_address.reset();
LOG(ERROR) << "Cannot start http server for devtools. Stop devtools.";
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&ServerStartedOnUI,
handler,
thread,
server_wrapper,
server_socket_factory,
base::Passed(&ip_address)));
}
Chromim 65-devtools_http_handler.cc
void StartServerOnHandlerThread(
base::WeakPtr<DevToolsHttpHandler> handler,
std::unique_ptr<base::Thread> thread,
std::unique_ptr<DevToolsSocketFactory> socket_factory,
const base::FilePath& output_directory,
const base::FilePath& frontend_dir,
const std::string& browser_guid,
bool bundles_resources) {
DCHECK(thread->task_runner()->BelongsToCurrentThread());
std::unique_ptr<ServerWrapper> server_wrapper;
std::unique_ptr<net::ServerSocket> server_socket =
socket_factory->CreateForHttpServer();
std::unique_ptr<net::IPEndPoint> ip_address(new net::IPEndPoint);
if (server_socket) {
server_wrapper.reset(new ServerWrapper(handler, std::move(server_socket),
frontend_dir, bundles_resources));
if (server_wrapper->GetLocalAddress(ip_address.get()) != net::OK)
ip_address.reset();
} else {
ip_address.reset();
}
if (ip_address) {
std::string message = base::StringPrintf(
"\nDevTools listening on ws://%s%s\n", ip_address->ToString().c_str(),
browser_guid.c_str());
fprintf(stderr, "%s", message.c_str());
fflush(stderr);
// Write this port to a well-known file in the profile directory
// so Telemetry can pick it up.
if (!output_directory.empty()) {
base::FilePath path =
output_directory.Append(kDevToolsActivePortFileName);
std::string port_target_string = base::StringPrintf(
"%d\n%s", ip_address->port(), browser_guid.c_str());
if (base::WriteFile(path, port_target_string.c_str(),
static_cast<int>(port_target_string.length())) < 0) {
LOG(ERROR) << "Error writing DevTools active port to file";
}
}
} else {
LOG(ERROR) << "Cannot start http server for devtools. Stop devtools.";
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&ServerStartedOnUI, std::move(handler), thread.release(),
server_wrapper.release(), socket_factory.release(),
std::move(ip_address)));
}
您会注意到65版本正在对ip_address值进行布尔检查,而54版本仅检查server_socket。
我意识到有一个未答复的帖子Cannot start http devtools,但已发布了3个月,没有任何回复。