WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
177803
Fix MSVC build with ENCRYPTED_MEDIA enabled
https://bugs.webkit.org/show_bug.cgi?id=177803
Summary
Fix MSVC build with ENCRYPTED_MEDIA enabled
Yoshiaki Jitsukawa
Reported
2017-10-03 01:35:16 PDT
Both MSVC 2015 and 2017 fail to compile MediaKeySession.cpp and CDMClearKey.cpp.
Attachments
Patch
(10.28 KB, patch)
2017-10-03 01:41 PDT
,
Yoshiaki Jitsukawa
no flags
Details
Formatted Diff
Diff
compiler error log for MediaKeySession.cpp
(2.44 KB, text/plain)
2017-10-03 22:29 PDT
,
Yoshiaki Jitsukawa
no flags
Details
Patch
(12.72 KB, patch)
2017-10-09 16:07 PDT
,
Yoshiaki Jitsukawa
no flags
Details
Formatted Diff
Diff
Patch
(10.22 KB, patch)
2021-02-08 11:06 PST
,
Don Olmstead
achristensen
: review+
Details
Formatted Diff
Diff
Patch
(12.96 KB, patch)
2021-02-08 14:56 PST
,
Don Olmstead
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Yoshiaki Jitsukawa
Comment 1
2017-10-03 01:41:47 PDT
Created
attachment 322502
[details]
Patch
Yoshiaki Jitsukawa
Comment 2
2017-10-03 01:58:02 PDT
MSVC fails to compile lambda capture lists like this: [this, weakThis = m_weakPtrFactory.createWeakPtr(*this), promise = WTFMove(promise)] so with the patch weakThis is created outside of the capture list.
Alex Christensen
Comment 3
2017-10-03 19:58:27 PDT
That ought to work. It's valid C++14. What is the error when compiling these files without this change?
Chris Dumez
Comment 4
2017-10-03 20:06:04 PDT
Yes, this should build fine. Those changes do not look good. Are you building without c++14 support enabled?
Yoshiaki Jitsukawa
Comment 5
2017-10-03 22:29:14 PDT
Created
attachment 322632
[details]
compiler error log for MediaKeySession.cpp For example I'm getting the attached errors when compiling MediaKeySession.cpp even with /std:c++14 option.
Alex Christensen
Comment 6
2017-10-04 13:25:45 PDT
Comment on
attachment 322502
[details]
Patch I think we need to find a better solution than this.
Yoshiaki Jitsukawa
Comment 7
2017-10-04 14:41:44 PDT
(In reply to Alex Christensen from
comment #6
)
> Comment on
attachment 322502
[details]
> Patch > > I think we need to find a better solution than this.
I agree to that. Thank you!
Zan Dobersek
Comment 8
2017-10-05 01:15:29 PDT
Try adding a simple private `createWeakPtr()` method on the MediaKeySession class, and call that in the lambda's capture list:
> WeakPtr<MediaKeySession> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
The build error seems to indicate a compiler bug in how the `*this` object is deduced in the capture list. I also wonder whether capturing `weakThis = m_weakPtrFactory.createWeakPtr(*this)` before the plain `this` pointer would have any effect.
Yoshiaki Jitsukawa
Comment 9
2017-10-05 02:20:17 PDT
(In reply to Zan Dobersek from
comment #8
)
> Try adding a simple private `createWeakPtr()` method on the MediaKeySession > class, and call that in the lambda's capture list: > > > WeakPtr<MediaKeySession> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } > > The build error seems to indicate a compiler bug in how the `*this` object > is deduced in the capture list. I also wonder whether capturing `weakThis = > m_weakPtrFactory.createWeakPtr(*this)` before the plain `this` pointer would > have any effect.
Thanks, let me try those.
Yoshiaki Jitsukawa
Comment 10
2017-10-09 16:07:08 PDT
Created
attachment 323238
[details]
Patch
Yoshiaki Jitsukawa
Comment 11
2017-10-09 16:19:29 PDT
(In reply to Zan Dobersek from
comment #8
)
> Try adding a simple private `createWeakPtr()` method on the MediaKeySession > class, and call that in the lambda's capture list: > > > WeakPtr<MediaKeySession> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } > > The build error seems to indicate a compiler bug in how the `*this` object > is deduced in the capture list. I also wonder whether capturing `weakThis = > m_weakPtrFactory.createWeakPtr(*this)` before the plain `this` pointer would > have any effect.
Both of them didn't work and it seems that there's something wrong with deduction in nested lambda so I attached another patch to create a weak ptr at the outermost capture list.
Alex Christensen
Comment 12
2017-10-10 12:39:52 PDT
Comment on
attachment 323238
[details]
Patch I think this approach looks ok.
Yoshiaki Jitsukawa
Comment 13
2017-10-10 14:23:15 PDT
(In reply to Alex Christensen from
comment #12
)
> Comment on
attachment 323238
[details]
> Patch > > I think this approach looks ok.
Thank you!
WebKit Commit Bot
Comment 14
2017-10-10 14:51:51 PDT
Comment on
attachment 323238
[details]
Patch Clearing flags on attachment: 323238 Committed
r223148
: <
http://trac.webkit.org/changeset/223148
>
WebKit Commit Bot
Comment 15
2017-10-10 14:51:52 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 16
2017-10-10 14:52:51 PDT
<
rdar://problem/34920322
>
Matt Lewis
Comment 17
2017-10-10 15:58:14 PDT
This caused internal failures. For more information, refer to the reviewer for more details.
Matt Lewis
Comment 18
2017-10-10 15:59:44 PDT
Reverted
r223148
for reason: This caused build failures. Committed
r223153
: <
http://trac.webkit.org/changeset/223153
>
Yoshiaki Jitsukawa
Comment 19
2017-10-23 06:55:57 PDT
(In reply to Matt Lewis from
comment #17
)
> This caused internal failures. For more information, refer to the reviewer > for more details.
So would you give me some information to help fix the failures?
Don Olmstead
Comment 20
2021-02-08 11:06:39 PST
Created
attachment 419609
[details]
Patch
Alex Christensen
Comment 21
2021-02-08 12:48:36 PST
Comment on
attachment 419609
[details]
Patch The original patch introduced some unused lambda capture 'this' instances: error: .../OpenSource/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp:357:10: error: lambda capture 'this' is not used [-Werror,-Wunused-lambda-capture] .../OpenSource/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp:461:10: error: lambda capture 'this' is not used [-Werror,-Wunused-lambda-capture] .../OpenSource/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp:505:10: error: lambda capture 'this' is not used [-Werror,-Wunused-lambda-capture] What a great reason to delay this patch for 3.5 years. This version doesn't touch that file, so it should be fine. If you want to also change CDMClearKey.cpp, just remove 'this' if you can.
Don Olmstead
Comment 22
2021-02-08 14:56:28 PST
Created
attachment 419633
[details]
Patch
EWS
Comment 23
2021-02-08 15:53:14 PST
Committed
r272557
: <
https://commits.webkit.org/r272557
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 419633
[details]
.
Darin Adler
Comment 24
2021-02-08 16:11:36 PST
Comment on
attachment 419633
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=419633&action=review
> Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp:326 > + m_instanceSession->loadSession(m_sessionType, *sanitizedSessionId, origin, [this, weakThis = makeWeakPtr(*weakThis), promise = WTFMove(promise), sanitizedSessionId = *sanitizedSessionId, identifier = WTFMove(identifier)] (Optional<CDMInstanceSession::KeyStatusVector>&& knownKeys, Optional<double>&& expiration, Optional<CDMInstanceSession::Message>&& message, CDMInstanceSession::SuccessValue succeeded, CDMInstanceSession::SessionLoadFailure failure) mutable {
Is this: weakThis = makeWeakPtr(*weakThis) Different from just writing this: weakThis ?
> Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp:438 > + m_instanceSession->updateLicense(m_sessionId, m_sessionType, sanitizedResponse.releaseNonNull(), [this, weakThis = makeWeakPtr(*weakThis), promise = WTFMove(promise), identifier = WTFMove(identifier)] (bool sessionWasClosed, Optional<CDMInstanceSession::KeyStatusVector>&& changedKeys, Optional<double>&& changedExpiration, Optional<CDMInstanceSession::Message>&& message, CDMInstanceSession::SuccessValue succeeded) mutable {
Ditto.
> Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp:559 > + m_instanceSession->closeSession(m_sessionId, [this, weakThis = makeWeakPtr(*weakThis), promise = WTFMove(promise), identifier = WTFMove(identifier)] () mutable {
Ditto.
> Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp:603 > + m_instanceSession->removeSessionData(m_sessionId, m_sessionType, [this, weakThis = makeWeakPtr(*weakThis), promise = WTFMove(promise), identifier = WTFMove(identifier)] (CDMInstanceSession::KeyStatusVector&& keys, Optional<Ref<SharedBuffer>>&& message, CDMInstanceSession::SuccessValue succeeded) mutable {
Ditto.
> Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp:490 > + [weakThis = makeWeakPtr(*weakThis), callback = WTFMove(callback), sessionWasClosed, changedKeys = WTFMove(changedKeys), succeeded] () mutable {
Ditto.
> Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp:573 > + [weakThis = makeWeakPtr(*weakThis), callback = WTFMove(callback), keyStatusVector = WTFMove(keyStatusVector), message = WTFMove(message), success]() mutable {
Ditto.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug