New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 733465 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocked on:
issue 653181

Blocking:
issue 708303



Sign in to add a comment

media_gpu!media::MediaFoundationVideoEncodeAccelerator::CreateHardwareEncoderMFT Creates an Implicit MTA

Project Member Reported by robliao@chromium.org, Jun 15 2017

Issue description

media_gpu!media::MediaFoundationVideoEncodeAccelerator::CreateHardwareEncoderMFT needs to ensure that it calls CoCreateInstance in an explicit MTA. Currently it's being called in an implicit MTA.

The fun of an implicit MTA is because it's implicit, there are no guarantees as to how long it will stick around.

CoCreateInstance stack
2:031> kn20
 # ChildEBP RetAddr  
00 007ac708 10102d0a base!base::debug::BreakDebugger+0x17 [f:\src\base\debug\debugger_win.cc @ 21]
01 007acc8c 103ae4a5 base!logging::LogMessage::~LogMessage+0x3ca [f:\src\base\logging.cc @ 786]
02 007acd58 103adb78 base!base::win::AssertComInitialized+0x95 [f:\src\base\win\com_init_util.cc @ 54]
03 007acd60 1e7025e3 base!base::win::`anonymous namespace'::HookManager::DCheckedCoCreateInstance+0x8 [f:\src\base\win\com_init_check_hook.cc @ 216]
04 007ad430 1e703d30 media_gpu!media::MediaFoundationVideoEncodeAccelerator::CreateHardwareEncoderMFT+0x5b3 [f:\src\media\gpu\media_foundation_video_encode_accelerator_win.cc @ 359]
05 007ad77c 1e6a1d31 media_gpu!media::MediaFoundationVideoEncodeAccelerator::GetSupportedProfiles+0x1e0 [f:\src\media\gpu\media_foundation_video_encode_accelerator_win.cc @ 111]
06 007ad7e8 11613444 media_gpu!media::GpuVideoEncodeAcceleratorFactory::GetSupportedProfiles+0xb1 [f:\src\media\gpu\gpu_video_encode_accelerator_factory.cc @ 130]
07 007ad808 116a423f content!media::GpuVideoEncodeAccelerator::GetSupportedProfiles+0x14 [f:\src\media\gpu\ipc\service\gpu_video_encode_accelerator.cc @ 288]
08 007ad9b8 1097cbba content!ui::GpuService::UpdateGPUInfoFromPreferences+0x14f [f:\src\services\ui\gpu\gpu_service.cc @ 138]
09 007adb70 116d9f27 content!content::GpuChildThread::CreateGpuService+0x2a [f:\src\content\gpu\gpu_child_thread.cc @ 259]
0a 007adccc 1097b35a content!ui::mojom::GpuMainStubDispatch::Accept+0x377 [f:\src\out\debug\gen\services\ui\gpu\interfaces\gpu_main.mojom.cc @ 191]
0b 007adce0 0190cd88 content!ui::mojom::GpuMainStub<mojo::RawPtrImplRefTraits<ui::mojom::GpuMain> >::Accept+0x3a [f:\src\out\debug\gen\services\ui\gpu\interfaces\gpu_main.mojom.h @ 128]
0c 007aded0 0190b9d6 bindings!mojo::InterfaceEndpointClient::HandleValidatedMessage+0x428 [f:\src\mojo\public\cpp\bindings\lib\interface_endpoint_client.cc @ 406]
0d 007adee0 01902423 bindings!mojo::InterfaceEndpointClient::HandleIncomingMessageThunk::Accept+0x16 [f:\src\mojo\public\cpp\bindings\lib\interface_endpoint_client.cc @ 128]
0e 007adfd0 0190c92a bindings!mojo::FilterChain::Accept+0x123 [f:\src\mojo\public\cpp\bindings\lib\filter_chain.cc @ 41]
0f 007ae098 01ab99df bindings!mojo::InterfaceEndpointClient::HandleIncomingMessage+0x9a [f:\src\mojo\public\cpp\bindings\lib\interface_endpoint_client.cc @ 292]
10 007ae388 01ab036d ipc!IPC::`anonymous namespace'::ChannelAssociatedGroupController::AcceptOnProxyThread+0x27f [f:\src\ipc\ipc_mojo_bootstrap.cc @ 776]
11 007ae3b8 01ab0695 ipc!base::internal::FunctorTraits<void (__thiscall IPC::`anonymous namespace'::ChannelAssociatedGroupController::*)(mojo::Message),void>::Invoke<scoped_refptr<IPC::`anonymous namespace'::ChannelAssociatedGroupController> const &,mojo::Message>+0x2d [f:\src\base\bind_internal.h @ 215]
12 007ae3d0 01ab0b7a ipc!base::internal::InvokeHelper<0,void>::MakeItSo<void (__thiscall IPC::`anonymous namespace'::ChannelAssociatedGroupController::*const &)(mojo::Message),scoped_refptr<IPC::`anonymous namespace'::ChannelAssociatedGroupController> const &,mojo::Message>+0x35 [f:\src\base\bind_internal.h @ 285]
13 007ae408 01abd1e4 ipc!base::internal::Invoker<base::internal::BindState<void (__thiscall IPC::`anonymous namespace'::ChannelAssociatedGroupController::*)(mojo::Message),scoped_refptr<IPC::`anonymous namespace'::ChannelAssociatedGroupController>,base::internal::PassedWrapper<mojo::Message> >,void __cdecl(void)>::RunImpl<void (__thiscall IPC::`anonymous namespace'::ChannelAssociatedGroupController::*const &)(mojo::Message),std::tuple<scoped_refptr<IPC::`anonymous namespace'::ChannelAssociatedGroupController>,base::internal::PassedWrapper<mojo::Message> > const &,0,1>+0x5a [f:\src\base\bind_internal.h @ 361]
14 007ae424 1004ac85 ipc!base::internal::Invoker<base::internal::BindState<void (__thiscall IPC::`anonymous namespace'::ChannelAssociatedGroupController::*)(mojo::Message),scoped_refptr<IPC::`anonymous namespace'::ChannelAssociatedGroupController>,base::internal::PassedWrapper<mojo::Message> >,void __cdecl(void)>::Run+0x24 [f:\src\base\bind_internal.h @ 339]
15 007ae43c 100b56ec base!base::Callback<void __cdecl(void),0,0>::Run+0x35 [f:\src\base\callback.h @ 91]
16 007ae50c 1013a3ac base!base::debug::TaskAnnotator::RunTask+0x1dc [f:\src\base\debug\task_annotator.cc @ 61]
17 007ae65c 10138822 base!base::MessageLoop::RunTask+0x1fc [f:\src\base\message_loop\message_loop.cc @ 419]
18 007ae670 10138e72 base!base::MessageLoop::DeferOrRunPendingTask+0x32 [f:\src\base\message_loop\message_loop.cc @ 432]
19 007ae710 1013eea0 base!base::MessageLoop::DoWork+0x112 [f:\src\base\message_loop\message_loop.cc @ 536]
1a 007ae7e0 1013a0af base!base::MessagePumpDefault::Run+0x90 [f:\src\base\message_loop\message_pump_default.cc @ 33]
1b 007ae8b8 101f981a base!base::MessageLoop::Run+0xbf [f:\src\base\message_loop\message_loop.cc @ 366]
1c 007aea48 1098967d base!base::RunLoop::Run+0xba [f:\src\base\run_loop.cc @ 112]
1d 007aee58 13611277 content!content::GpuMain+0x4fd [f:\src\content\gpu\gpu_main.cc @ 291]

 

Comment 1 by kbr@chromium.org, Jun 15 2017

Blockedon: 653181
Cc: kbr@chromium.org jbau...@chromium.org stanisc@chromium.org
Components: Internals>GPU>Internals
Status: Assigned (was: Available)
The change being proposed in https://chromium-review.googlesource.com/537334/ is related to  Issue 653181  so blocking on that.

Thanks for taking a look at this. I wasn't aware of these requirements.

I am working on a solution that would avoid calling CreateHardwareEncoderMFT() when GetSupportedProfiles() is called. GetSupportedProfiles() is always called in gpu startup as you can see from the stack. If I can get that working, we would still be calling CreateHardwareEncoderMFT(), but only if HW encode session is needed. That still happens on the main thread [0]. Can I revert any of your changes then, such that we initialize COm within GpuVideoEncodeAccelerator? 

[0] https://cs.chromium.org/chromium/src/media/gpu/ipc/service/gpu_video_encode_accelerator.cc?rcl=e800cdd4b314370ae8d49d55c1dc9cc73f9b8659&l=166
> Can I revert any of your changes then, such that we initialize COm within GpuVideoEncodeAccelerator? 

COM initialization is best done at a single place at the top level. This allows rationalization on when COM is expected to be shut down.

If components initialize COM on their own, then it will be hard to determine when/where COM is active.

It shouldn't be necessary to back out the change that enables MTA on GpuMain.
Project Member

Comment 4 by bugdroid1@chromium.org, Jun 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/98bb92d4f01372663087fca693c687b55a06c261

commit 98bb92d4f01372663087fca693c687b55a06c261
Author: Robert Liao <robliao@chromium.org>
Date: Fri Jun 16 01:47:26 2017

Reintroduce COM Initialization on the GpuMain Thread

In a series of errors, COM STA initialization was accidentally removed
from the GpuMain thread.

The first error [1] occurred on May 18, 2012 and wrapped COM
initialization in a trace event to attempt to measure startup timing.
Wrapping ScopedComInitializer is an error as it will initialize and
then immediately uninitialize COM at the end of the scope. At this
point any CoCreateInstance call underneath created an implicit COM MTA
if the requested objected allowed it and proceed with the call.

The second error [2] occurred on April 2, 2013. The erroneous scope
gave the impression that COM wasn't being used at all and it was safe
to just not initialize COM on GpuMain.

Chrome will be DCHECKing COM initialization as part of
 http://crbug.com/708303  and it revealed that COM was being used by
Media Foundation calls occurring on GpuMain.

At the same time we want to avoid pumping messages on GpuMain now.

As a result, this change reintroduces the COM initialization but 
configured as an MTA.

[1]
https://chromium.googlesource.com/chromium/src/+/d13f35da2d73cca3d7de8ca35b9a8cb4d668264a

[2]
https://chromium.googlesource.com/chromium/src/+/531f3f0bd7698a8b136c8d7624b0e4907626a1b3

BUG= 733465 

Change-Id: I9e2c9157ada3ad988ba14ddf0d841920c4bc012f
Reviewed-on: https://chromium-review.googlesource.com/537334
Commit-Queue: Robert Liao <robliao@chromium.org>
Reviewed-by: Stanislav Chiknavaryan <stanisc@chromium.org>
Reviewed-by: John Bauman <jbauman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#479892}
[modify] https://crrev.com/98bb92d4f01372663087fca693c687b55a06c261/content/gpu/gpu_main.cc

Status: Fixed (was: Assigned)

Sign in to add a comment