Friday, May 24, 2013

chromium Render process

Let's look at some important call stack.

#1 Create Render process

1. Render process creation on render thread.

- zygote forks Render process
- RendererMain() is entry point of Render process.

base::MessageLoop::Run() at message_loop.cc:321 0x970ee6 
content::RendererMain() at renderer_main.cc:235 0x118362d 
content::RunZygote() at content_main_runner.cc:385 0xe0aa08 
content::RunNamedProcessTypeMain() at content_main_runner.cc:441 0xe0ac4e 
content::ContentMainRunnerImpl::Run() at content_main_runner.cc:756 0xe0bcc3 
content::ContentMain() at content_main.cc:35 0xe09fbf 
main() at shell_main.cc:36 0x42a43d 

highlight in content::RendererMain()

- create MessangeLoop, PowerMonitor, StaticsRecoder, WebRTC and etc.
- create RenderProcessImpl on stack. FYI, RenderProcessImpl extends RenderProcess that extends ChildProcess.
- create RenderThreadImpl
- call MessageLoop::Run()

highlight in RenderThreadImpl::Init()

- ChildProcess::current()->set_main_thread(this);
- create AppCache, DB, Stroage and etc.
- install varios filters: video, audio, db, WebRTC
- callback embeder via ContentRendererClient::RenderThreadStarted()

how to create SyncChannel

- RenderThreadImpl extends ChildThread
- ChildThread::Init() can be called

  • create SyncChannel
  • create various dispatcher and filters.

2. Receive ViewMsg_New on ipc thread

ChannelProxy::Context::OnMessageReceivedNoFilter() send OnDispatchMessage closure to render thread.
listener_task_runner_->PostTask(FROM_HERE, base::Bind(&Context::OnDispatchMessage, this, message));

IPC::ChannelProxy::Context::OnMessageReceivedNoFilter() at ipc_channel_proxy.cc:104 0x1abfd7c 
IPC::SyncChannel::SyncContext::OnMessageReceived() at ipc_sync_channel.cc:346 0x1acf589 
IPC::internal::ChannelReader::DispatchInputData() at ipc_channel_reader.cc:90 0x1ac44a8 
IPC::internal::ChannelReader::ProcessIncomingMessages() at ipc_channel_reader.cc:32 0x1ac4031 
IPC::Channel::ChannelImpl::OnFileCanReadWithoutBlocking() at ipc_channel_posix.cc:641 0x1abd047 
base::MessagePumpLibevent::FileDescriptorWatcher::OnFileCanReadWithoutBlocking() at message_pump_libevent.cc:102 0x924f10 
base::MessagePumpLibevent::OnLibeventNotification() at message_pump_libevent.cc:359 0x926966 
event_process_active() at event.c:385 0x1c53385 
event_base_loop() at event.c:525 0x1c536a8 
base::MessagePumpLibevent::Run() at message_pump_libevent.cc:262 0x925ee9 
base::MessageLoop::RunInternal() at message_loop.cc:441 0x97179e 
base::MessageLoop::RunHandler() at message_loop.cc:414 0x971648 
base::RunLoop::Run() at run_loop.cc:45 0x9a2020 
base::MessageLoop::Run() at message_loop.cc:321 0x970ee6 
base::Thread::Run() at thread.cc:159 0x9d6092 
base::Thread::ThreadMain() at thread.cc:204 0x9d621f 
base::() at platform_thread_posix.cc:76 0x9ca40a 
start_thread() at pthread_create.c:308 0x7ffff3b67e9a 
clone() at clone.S:112 0x7ffff2c49ccd 
0x0 

3. Create RenderView on render thread

-  Send(new ViewMsg_New(params)) called by RenderViewHostImpl::CreateRenderView() in Browser process
- ipc thread send ViewMsg_New msg to render thread.
- RenderThreadImpl receives ViewMsg_New msg.

content::RenderThreadImpl::OnCreateNewView(const ViewMsg_New_Params& params) at render_thread_impl.cc:1185
content::RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) at render_thread_impl.cc:1154
content::ChildThread::OnMessageReceived() at child_thread.cc:271 0xcb2809 
IPC::ChannelProxy::Context::OnDispatchMessage() at ipc_channel_proxy.cc:261 0x1ac0867 
base::internal::RunnableAdapter{void () at bind_internal.h:190 0x1ac3635 
base::internal::InvokeHelper{false, void, base::internal::RunnableAdapter{void () at bind_internal.h:899 0x1ac32af 
base::internal::Invoker{2, base::internal::BindState{base::internal::RunnableAdapter{void () at bind_internal.h:1,257 0x1ac2db6 
base::Callback{void () at callback.h:396 0x44840a 
base::MessageLoop::RunTask() at message_loop.cc:484 0x971c03 
base::MessageLoop::DeferOrRunPendingTask() at message_loop.cc:496 0x971d32 
base::MessageLoop::DoWork() at message_loop.cc:688 0x972673 
base::MessagePumpDefault::Run() at message_pump_default.cc:29 0x979fc9 
base::MessageLoop::RunInternal() at message_loop.cc:441 0x97179e 
base::MessageLoop::RunHandler() at message_loop.cc:414 0x971648 
base::RunLoop::Run() at run_loop.cc:45 0x9a2020 
base::MessageLoop::Run() at message_loop.cc:321 0x970ee6 
content::RendererMain() at renderer_main.cc:235 0x118362d 
content::RunZygote() at content_main_runner.cc:385 0xe0aa08 
content::RunNamedProcessTypeMain() at content_main_runner.cc:441 0xe0ac4e 
content::ContentMainRunnerImpl::Run() at content_main_runner.cc:756 0xe0bcc3 
content::ContentMain() at content_main.cc:35 0xe09fbf 
main() at shell_main.cc:36 0x42a43d 


highlight of RenderThreadImpl::OnCreateNewView()

- call EnsureWebKitInitialized()

  •  WebKit::initialize() 
  •  Init Compositor thread 

 - create RenderViewImpl that extends WebViewClient

  •  create WebViewImpl 
  •  deal with compositor surface, settings, and etc.

#2 send msg

1. send on render thread

IPC::ChannelProxy::Send(Message* message) at ipc_channel_proxy.cc
IPC::SyncChannel::SendWithTimeout() at ipc_sync_channel.cc:452 0x1acfed7 
IPC::SyncChannel::Send() at ipc_sync_channel.cc:437 0x1acfdb2 
content::ChildThread::Send() at child_thread.cc:177 0xcb1d18 
content::RenderThreadImpl::Send() at render_thread_impl.cc:530 0x112a21f 
content::RenderWidget::Send() at render_widget.cc:366 0x11711dc 
content::RenderViewImpl::Send() at render_view_impl.cc:4,404 0x114cfdf 
content::RenderViewImpl::UpdateTargetURL() at render_view_impl.cc:2,376 0x11420b4 
content::RenderViewImpl::setMouseOverURL() at render_view_impl.cc:2,417 0x1142328 

2. send on ipc thread

IPC::Channel::ChannelImpl::Send() at ipc_channel_posix.cc:495 0x1abbeda 
IPC::Channel::Send() at ipc_channel_posix.cc:976 0x1abe95d 
IPC::ChannelProxy::Context::OnSendMessage() at ipc_channel_proxy.cc:186 0x1ac02e6 
base::internal::RunnableAdapter{void () at bind_internal.h:190 0x1ac398a 
base::internal::InvokeHelper{false, void, base::internal::RunnableAdapter{void () at bind_internal.h:899 0x1ac34c6 
base::internal::Invoker{2, base::internal::BindState{base::internal::RunnableAdapter{void () at bind_internal.h:1,257 0x1ac3187 
base::Callback{void () at callback.h:396 0x44840a 
base::MessageLoop::RunTask() at message_loop.cc:484 0x971c03 
base::MessageLoop::DeferOrRunPendingTask() at message_loop.cc:496 0x971d32 
base::MessageLoop::DoWork() at message_loop.cc:688 0x972673 
base::MessagePumpLibevent::Run() at message_pump_libevent.cc:235 0x925d98 
base::MessageLoop::RunInternal() at message_loop.cc:441 0x97179e 
base::MessageLoop::RunHandler() at message_loop.cc:414 0x971648 
base::RunLoop::Run() at run_loop.cc:45 0x9a2020 
base::MessageLoop::Run() at message_loop.cc:321 0x970ee6 
base::Thread::Run() at thread.cc:159 0x9d6092 
base::Thread::ThreadMain() at thread.cc:204 0x9d621f 
base::() at platform_thread_posix.cc:76 0x9ca40a 
start_thread() at pthread_create.c:308 0x7ffff3b67e9a 
clone() at clone.S:112 0x7ffff2c49ccd 
0x0 



No comments:

Post a Comment