castlabs / electron-releases

castLabs Electron for Content Security
https://castlabs.com/resources/downstream/
MIT License
227 stars 43 forks source link

components.whenReady() not rejecting on error #169

Open toschlog opened 1 year ago

toschlog commented 1 year ago

My app has for a while been using v20.0.0+wvcus which was downloading version 4.10.2557.0 of the Widevine CDM. Sometime recently, though I'm not sure when, it stopped downloading the CDM. This was fine for existing users who already had it downloaded, but rendered the app unusable for new users. My log file shows that where the is no CDM present the components.status() call is returning status of 'up-to-date' and version of null for "Google Widevine Windows CDM". I would expect the whenReady() call to reject the promise; the null value for version seems to indicate that the CDM was not downloaded.

The bigger problem, actually, is that the CDM stopped downloading, but I don't know if this is Castlabs' problem. (Do those files come from Google?) I would expect that we'd be notified if a version is deprecated, so I'm guessing that there's a server problem or someone accidentally deleted the CDM. I'm happy to file a report for this issue if you can direct me to the right forum.

I've worked around the issue by upgrading to v26.4.2+wvcus which successfully downloads CDM 4.10.2710.0, but this is pretty poor solution because it will take us a few days to QA the new release and then a while for users to update.

Thanks.

khwaaj commented 1 year ago

This took us a bit by surprise as well because Google has been pretty lenient in keeping the CDM available for older releases. Their policy is to support (at least) the last 11 stable Chromium releases through the Component Updater, and historically they have mostly kept support for far longer than that.

Now however, it seems they are more strictly observing this policy, and Chromium versions outside this window has lost the ability to get a CDM. I've updated the Wiki to try and reflect this more clearly.

Our recommendation is to regularly update, and ideally make sure to stay within the Electron/ECS support window, which is the last three stable releases. This would ensure you get the latest security updates, and also that you remain within the Google policy for the CDM above.

khwaaj commented 1 year ago

About the whenReady() issue, I will look into it. I agree that this problem should cause a rejection of the promise.

There are some potential complications here though. For one I'm guessing we are not actually getting an error from the Component Updater (because that would trigger a rejection already). Secondly, on Windows, there are actually two different CDMs (L3 and L1), which can make the decision to reject or not ambiguous.

khwaaj commented 1 year ago

I confirmed that the Component Updater is not returning an error, which is why the promise is not rejected. While we consider what to do to improve this a relatively simple check can suffice as a workaround, e.g:

app.whenReady().then(async () => {
  await components.whenReady();
  const status = components.status();
  console.log('components status:', status);
  if (!status[components.WIDEVINE_CDM_ID].version) {
    throw Error("No valid CDM installed");
  }
  createWindow();
});

For applications requiring the L1 CDM on Windows a check for components.MEDIA_FOUNDATION_WIDEVINE_CDM_ID could also be be a good idea.

khwaaj commented 1 year ago

We have made some improvements to the Components API to have better control and error reporting, which will roll out in the upcoming builds. Among the improvements are some extra checks that will catch the case where no CDM is installed.

First out of the door is v25.9.3+wvcus.2, and v26-v28 are in the queue to be updated.