VOOZH about

URL: https://phabricator.services.mozilla.com/D77892

⇱ ⚙ D77892 Bug 1623971 - P16: Add a method to set image to SMTC thumbnail


Bug 1623971 - P16: Add a method to set image to SMTC thumbnail
ClosedPublic

Authored by chunmin on Jun 2 2020, 7:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 26, 4:55 AM
Unknown Object (File)
May 16 2026, 6:21 PM
Unknown Object (File)
Apr 26 2026, 12:26 AM
Unknown Object (File)
Apr 3 2026, 11:21 AM
Unknown Object (File)
Mar 29 2026, 10:19 AM
Unknown Object (File)
Mar 20 2026, 12:22 AM
Unknown Object (File)
Mar 19 2026, 11:30 PM
Unknown Object (File)
Mar 19 2026, 11:24 PM
Subscribers

Details

Summary

Add a method to set an image to SMTC's thumbmail asynchronously

Diff Detail

Event Timeline

phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.
chunmin edited the summary of this revision. (Show Details)
alwu requested changes to this revision.Jun 4 2020, 6:40 PM
alwu added inline comments.
widget/windows/WindowsSMTCProvider.cpp
18

I don't think test-only code should exist in this patch, especially considering they would all be removed in next patch.

33

We have done , so we are already able to access and other classes inside , right?

39

nit : Would we consider to use only instead?

39

nit : reorder those by alphabet order.

65

No need to do that, you can capture into the lambda which would allow you to use directly inside the lambda.

200

Why we load the thumbnail after calling ? And would you consider move into ? Because that seems a part of setting metadata.

458

Same here.

471–472

nit : we have done so we can use directly without having a scope name.

475–476

I wonder if we need to assert both and are not null, because they are not set in this function. Adding that assertion can ensure we always call in the expected situation.

480

capture then you are able to use .

482

why need ?

502

Don't mess the test-only code with the production code. If this method would only be complete when applying the change in next patch, then they should be merged together. Otherwise, you should consider using another way to separate them.

510

Would we modify ? If not, use .

512

Use following format in order to follow other checks in this function.

if (FAILED(hr)) {
 LOG("XXXX");
 return;
 }
515

nit : would you consider to separate those comments and put them just above the line where the operation is going to be executed?

widget/windows/WindowsSMTCProvider.h
96

nit : to reduce redundant scope description, because this type has been used mutiple times.

This revision now requires changes to proceed.Jun 4 2020, 6:40 PM
Comment Actions

will review after current set of issues are addressed

widget/windows/WindowsSMTCProvider.cpp
18

The purpose of embedding the test-only stuff is to demonstrate that the needs the raw binary data of an image file, including its file header.

The test-only part in this patch could definitely be removed in this patch once the usage of is illustrated explicitly.

33

yeah, good catch.

39

Sure.

200
  1. I guess one of the reason for having is to set . Thumbnail is not a property within so it shouldn't be there.
  2. will load the image asynchronously. The display interface will updated when upon image is loaded.
475–476

would be created/reset in . I'll add an assertion to make sure would only be called after is executed.

On the other hand, would be created from inside so it would always be non-null.

502

The intention of whole test stuff is to make this clear: The needs the raw binary data of an image file, including its file header.

512

I'll add a log if it fails.

widget/windows/WindowsSMTCProvider.h
96

I'll move from .cpp to .h

chunmin marked 15 inline comments as done.
alwu added inline comments.
widget/windows/WindowsSMTCProvider.cpp
501

Because it would be done asynchrously, at the time this function run, is it possible that we've closed the ?

If so, we could add a check to abort following steps if is already closed.


Or, is it possible to tell that we want to cancel the callback?

widget/windows/WindowsSMTCProvider.h
96

nit : I would prefer only use in the file, which can prevent from polluting other files which include this file. So that is why I proposed to use , not to use namespace directly.

Comment Actions

hopefully straightforward issues to resolve.
please feel free to ping me when you update so that i can sign off

thanks!

widget/windows/WindowsSMTCProvider.cpp
522

it's unclear to me through code inspection that these two calls are threadsafe. but, just want to call out that these may end up being called on another thread and want to confirm that you thought about it.

widget/windows/WindowsSMTCProvider.h
43

same concern here-- it might be possible to addref/release in multiple threads. is this refcounting threadsafe?

This revision now requires changes to proceed.Jun 11 2020, 4:51 PM
widget/windows/WindowsSMTCProvider.cpp
501

The only function I found is [1]. Another way to do so is to drop/reset since would be re-initialized every time is called.

However, I am not sure if it's safe to call and (or ) at the same time. Those APIs are poorly documented. I am not sure if they are thread-safe. Also, it's hard to test them manually, to see if they are thread-safe, since I cannot find a place to insert a delay when the data is being written or flushed.

I guess it's fine to keep writing data even is closed. Chrome does the same way, without canceling the writing task when the whole class is deconstructed [2].

If the image would be cached, then it might be reused if the first image upon is the same as the cached one.

[1] https://docs.microsoft.com/en-us/uwp/api/windows.storage.streams.idatawriter.flushasync?view=winrt-19041#Windows_Storage_Streams_IDataWriter_FlushAsync
[2] https://source.chromium.org/chromium/chromium/src/+/master:components/system_media_controls/win/system_media_controls_win.cc;l=53;drc=b3af28c015f96bbd3c17d39b16b4e5778510578e?originalUrl=https:%2F%2Fcs.chromium.org%2F

522

This is the only place that can be called, so it's safe.

For , I am not really sure. The [2] inherits from , which is safe to call from user interface threads [3]. It doesn't state it can be called from different threads at the same time. However, chrome implements this in the same way [1] so I guess it's ok to follow.

[1] https://docs.microsoft.com/en-us/previous-versions/windows/desktop/mediatransport/isystemmediatransportcontrolsdisplayupdater
[2] https://docs.microsoft.com/en-us/windows/win32/api/inspectable/nn-inspectable-iinspectable?redirectedfrom=MSDN#remarks
[3] https://source.chromium.org/chromium/chromium/src/+/master:components/system_media_controls/win/system_media_controls_win.cc;l=257,302?originalUrl=https:%2F%2Fcs.chromium.org%2F

widget/windows/WindowsSMTCProvider.h
43

I'll see if I can make it .

chunmin edited the summary of this revision. (Show Details)
Comment Actions

please make sure alwu knows about changing the refcounting to be threadsafe

This revision is now accepted and ready to land.Jun 11 2020, 9:45 PM
widget/windows/WindowsSMTCProvider.cpp
501

Ah, the image won't need to be cached. We need to disconnect the image fetching process if we have one.

If chrome's implementation is right, I guess it's ok to call in .

chunmin marked 2 inline comments as done.

Revision Contents

PathSize
widget/
windows/
28 lines
153 lines
CommitParentsAuthorSummaryDate
2b7c4c1293c8Chun-Min Chang
Bug 1623971 - P16: Add a method to set image to SMTC thumbnail r=alwu,thomasmo (Show More…)
StatusAuthorRevision
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin
Closedchunmin

Diff 298964

widget/windows/WindowsSMTCProvider.h

Loading...

widget/windows/WindowsSMTCProvider.cpp

Loading...