Skip to content

Conversation

@shubham1g5
Copy link
Contributor

Spec: https://docs.google.com/document/d/1WWhgG6cyKm7nN2pUn8lty72F3ZN6D1xWqTZsIlHX4z8/edit#heading=h.xlb7kbytn7rw

  • Parses a new 'lazy' atrribute for resource definition
  • Skips downloading the lazy media resource during install
  • Initiate a Work manager task MissingMediaDownloadWorker on login to initiate lazy media download. This task today takes help of our existing multimedia verification to find out the lazy resources and installs them one by one in background
  • Changes Media Layouts to support requesting for missing media on user click

cross-request: dimagi/commcare-core#899

@shubham1g5
Copy link
Contributor Author

@ctsims Made the discussed changes in last few commits.

@shubham1g5 shubham1g5 requested a review from ctsims June 7, 2020 18:05
Copy link
Member

@ctsims ctsims left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Shubham,

Thanks for processing through the performance stuff. I reviewed the new commits and had a couple of questions and one or two suggestions.

In particular I'd like to understand why the model needed to be changed to support a worker per app version #, since that can have pretty significant runaway effects with multiple workers all reading/writing over similar tables / files at the same time.

Logger.log(LogTypes.TYPE_MAINTENANCE, "An error occured while lazy downloading a media resource : " + it.message)
return handleRecoverResourceFailure(it).data
}
if (!HiddenPreferences.hasLazyMediaDownloaded()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we'd ever been running lazy media installers for multiple app versions. Are we lazy installing the upgrade table as well as the installed version? or is this due to some behavior that happens after handing over between updates being applied??

Copy link
Contributor Author

@shubham1g5 shubham1g5 Jun 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only A new app update can introduce new lazy resources, so once we have successfully run this task for version x, we don't need to run it again for the same version until user updates to a different version.

Retrospectively, a better change here will be to just maintain a single app pref across all versions and reset that flag after an app update.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. I was reviewing by commit, which was silly, and I missed this was old. Sorry for the noise.

}
return Result.failure()
val result = MissingMediaDownloadHelper.downloadAllLazyMedia()
return if (result == AppInstallStatus.Installed) Result.success() else Result.retry()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we only want to retry automatically on specific errors?

In the handling list above, 3 of the 4 errors wouldn't be good for us to run a retry on

ctsims
ctsims previously approved these changes Jun 8, 2020
Copy link
Member

@ctsims ctsims left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No feedback on the latest round, so unless I'm missing anything this should be good to go.

@shubham1g5
Copy link
Contributor Author

@ctsims thanks. Also want to make sure that you have had a chance to go through the cross-requested core PR.

@shubham1g5
Copy link
Contributor Author

Made one more functional change to only show the audio missing toast when the audio button is visible.

ctsims
ctsims previously approved these changes Jun 10, 2020
@shubham1g5 shubham1g5 requested a review from ctsims June 11, 2020 17:12
@shubham1g5 shubham1g5 merged commit 01d69c5 into master Jun 11, 2020
@shubham1g5 shubham1g5 deleted the multimediaChanges branch June 11, 2020 17:55
@shubham1g5
Copy link
Contributor Author

@ctsims I just realized that we don't actually rate limit media requests but only the profile files which is the starting point for an update. Therefore I am worried that these lazy mm requests won't get rate limited at all slowing down other parts of the system. Is it worth adding a flag to these request saying that these are not part of a blocking update and hence it's fine to rate limit these.

@ctsims ctsims restored the multimediaChanges branch July 20, 2020 20:33
@ctsims
Copy link
Member

ctsims commented Jul 20, 2020

@shubham1g5 I think that's a really good idea, and we can avoid setting that flag for Media that's actually on the screen when the user makes the direct request to download a file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants