Search code examples
cobalt

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


When test with https://qual-e.appspot.com with cobalt rc_11 version, the key move too slow(5s+), sometimes the focus even can not move at all, it's hard to test with the page, after checking with the cpu usage, the MainWebModule used 98% CPU, so is there any way to improve it?

1> CPU usage of MainWebModule is 98% when move the focus

CPU Usage

2> The trace log of when move the focus

What's the MainWebModule doing?

3> the call backtrace of 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>focus move backtrace in Youtube(the same cobalt binary, no this issue)

[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]

Solution

  • This is fixed at Cobalt 11.78008 https://cobalt.googlesource.com/cobalt/+/810d1764791f7924402f1686ea98ed36ff8b36cb

    It was caused by the mixture of Qual-E focus manager logic and Cobalt layout manager logic. We enhanced the layout manager logic by decoupling laying out box tree and generating render tree.