Code in media_theplatform_mpx_form_media_browser() suffers from critical performance issues with any medium to large amount of MPX files. The problem is that the form is unpaginated, which means it has to load *all* MPX videos. This means calling media_theplatform_mpx_get_all_mpx_videos(), which on our site returns about 27,000 records.

This then also means that for each MPX video, it individually does a file_load() on each one, which is horrible for performance. At the least, file_load_multiple() should be used, but even then, it should not be done for 27,000 files all at once.

I don't know what the solution is for fixing these media browser tabs, it just seems unfixable without any sort of actual pagination. I realized that once our MPX videos were injested as files, we could just use the normal Media browser tabs which are nicely paginated with AJAX and only load/display 50 at a time.

In the end I had to just completely disable the media browser tabs provided by media_theplatform_mpx:

/**
 * Implements hook_module_implements_alter().
 */
function mymodule_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'media_browser_plugin_info') {
    unset($implementations['media_theplatform_mpx']);
  }
}

Comments

boyinasantosh’s picture

Hi Dave Reid,

Even i am facing performance issue. Were you able to implement pagination for MPX videos listing?
Kindly share some thoughts if we need to have pagination implemented.

dave reid’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev

I have not been able to implement them yet.

dave reid’s picture

At this point I'm thinking to just remove the tabs completely. I don't think they provide any benefit, and just end up duplicating work that is done by the existing Views-powered tabs from Media module. As a last resort we could rewrite these tabs as Views displays.

dave reid’s picture

Component: Code » Media browser integration
dave reid’s picture

Title: media_theplatform_mpx_form_media_browser() unscalable and unpaginated » Remove media browser plugins
Assigned: Unassigned » dave reid
Priority: Critical » Major

After talking with some major people using this module on projects, it appears no one is using these media browser tabs, so we're going to remove them since they do not work.

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new9.83 KB
dave reid’s picture

StatusFileSize
new10.34 KB

Removed files from .info.

dave reid’s picture

StatusFileSize
new15.33 KB

Found more CSS, JS, and API functions that can be removed.

mtift’s picture

Issue summary: View changes
StatusFileSize
new17.5 KB
new13.59 KB

This is a feature I've never used and I'm not sure how other people would use it. However, it seems like we should add something to the default media browser view that allows the user to select an MPX video.

This is before:

This is after:

Probably beyond the scope of this issue, but it seems relevant.

Otherwise, +1 from me. I'll all for improving performance!

dave reid’s picture

Status: Needs review » Reviewed & tested by the community

@mtift: You should be able to see those items under the 'Library' tab. My files only shows records that have file_managed.uid == your current user ID. And it appears that MPX imports videos assigned to the anonymous user: #2421769: Imported MPX videos assigned to the anonymous user.

  • Dave Reid committed 26d3254 on 7.x-3.x authored by mtift
    Issue #2333727 by Dave Reid, mtift: Removed media browser plugins that...
dave reid’s picture

Status: Reviewed & tested by the community » Fixed

Committed #8 to 7.x-3.x.

mtift’s picture

Excellent! Thanks, Dave!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.