使用 https://qual-e.appspot.com 测试时,按键移动太慢

The key moved too slow when test with https://qual-e.appspot.com

https://qual-e.appspot.com和cobalt rc_11版本测试时,按键移动太慢(5s+),有时焦点甚至根本不能移动,很难用页面测试,之后检查 cpu 使用情况,MainWebModule 使用了 98% CPU,那么有什么方法可以改善它吗?

1> CPU 移动焦点时 MainWebModule 的使用率为 98%

2>移动焦点时的跟踪日志

3> UpdateComputedStylesAndLayoutBoxTree 调用回溯

[cobalt]>       cobalt::layout::UpdateComputedStylesAndLayoutBoxTree() [0xcad0a0]
[cobalt]>       cobalt::layout::LayoutManager::Impl::DoSynchronousLayout() [0xc919b4]
[cobalt]>       cobalt::dom::Document::DoSynchronousLayout() [0x2c3fe8]
[cobalt]>       cobalt::dom::HTMLElement::offset_width() [0x2ec704]
[cobalt]>       cobalt::dom::(anonymous namespace)::get_offsetWidth() [0xecf80c]
[cobalt]>       js::Invoke() [0xa55a60]
[cobalt]>       js::Invoke() [0xa56348]
[cobalt]>       js::InvokeGetter() [0xa564e0]
[cobalt]>       js::BaseProxyHandler::get() [0x9ee84c]
[cobalt]>       js::Proxy::get() [0x9f47f0]
[cobalt]>       js::GetProperty() [0xa45c74]
[cobalt]>       Interpret() [0xa4b578]
[cobalt]>       js::RunScript() [0xa557c8]
[cobalt]>       js::Invoke() [0xa55b24]
[cobalt]>       js::Invoke() [0xa56348]
[cobalt]>       JS::Call() [0x931614]
[cobalt]>       cobalt::dom::MozjsEventListener::HandleEvent() [0xeb448c]
[cobalt]>       cobalt::dom::EventListener::HandleEvent() [0x338e30]
[cobalt]>       cobalt::dom::EventTarget::FireEventOnListeners() [0x2d7e40]
[cobalt]>       cobalt::dom::Node::DispatchEvent() [0x3100fc]
[cobalt]>       cobalt::dom::Window::InjectEvent() [0x322e80]
[cobalt]>       cobalt::browser::WebModule::Impl::InjectInputEvent() [0x850ac]
[cobalt]>       cobalt::browser::WebModule::Impl::InjectKeyboardEvent() [0x863d0]
[cobalt]>       base::internal::Invoker<>::Run() [0x8db04]
[cobalt]>       MessageLoop::RunTask() [0xc1e3c]
[cobalt]>       MessageLoop::DeferOrRunPendingTask() [0xc2c50]
[cobalt]>       MessageLoop::DoWork() [0xc3994]
[cobalt]>       base::MessagePumpDefault::Run() [0xc8ca8]
[cobalt]>       MessageLoop::RunInternal() [0xc4ca8]
[cobalt]>       base::RunLoop::Run() [0xd9438]
[cobalt]>       MessageLoop::Run() [0xc1708]
[cobalt]>       base::Thread::ThreadMain() [0xf4df0]
[cobalt]>       base::(anonymous namespace)::ThreadFunc() [0xf2984]
[cobalt]>       (anonymous namespace)::ThreadFunc() [0x11525c]

4>Youtube 中的焦点移动回溯(相同的钴二进制文件,没有这个问题)

[cobalt]>       cobalt::layout::UpdateComputedStylesAndLayoutBoxTree() [0xcad0a0]
[cobalt]>       cobalt::layout::Layout() [0xcae0cc]
[cobalt]>       cobalt::layout::LayoutManager::Impl::DoLayoutAndProduceRenderTree() [0xc929d4]
[cobalt]>       base::Timer::RunScheduledTask() [0xf6b40]
[cobalt]>       base::BaseTimerTaskInternal::Run() [0xf6f54]
[cobalt]>       MessageLoop::RunTask() [0xc1e3c]
[cobalt]>       MessageLoop::DeferOrRunPendingTask() [0xc2c50]
[cobalt]>       MessageLoop::DoDelayedWork() [0xc2d80]
[cobalt]>       base::MessagePumpDefault::Run() [0xc8ccc]
[cobalt]>       MessageLoop::RunInternal() [0xc4ca8]
[cobalt]>       base::RunLoop::Run() [0xd9438]
[cobalt]>       MessageLoop::Run() [0xc1708]
[cobalt]>       base::Thread::ThreadMain() [0xf4df0]
[cobalt]>       base::(anonymous namespace)::ThreadFunc() [0xf2984]
[cobalt]>       (anonymous namespace)::ThreadFunc() [0x11525c]
[cobalt]>       <unknown> [0xb6612e84]
[cobalt]>       <unknown> [0xb6612e84]

这已固定为 Cobalt 11.78008 https://cobalt.googlesource.com/cobalt/+/810d1764791f7924402f1686ea98ed36ff8b36cb

这是由 Qual-E 焦点管理器逻辑和 Cobalt 布局管理器逻辑混合引起的。我们通过解耦布局框树和生成渲染树来增强布局管理器逻辑。