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']);
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | Selection_019.png | 13.59 KB | mtift |
| #9 | Selection_018.png | 17.5 KB | mtift |
| #8 | 2333727-remove-media-browser-plugins.patch | 15.33 KB | dave reid |
| #7 | 2333727-remove-media-browser-plugins.patch | 10.34 KB | dave reid |
| #6 | 2333727-remove-media-browser-plugins.patch | 9.83 KB | dave reid |
Comments
Comment #1
boyinasantosh commentedHi 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.
Comment #2
dave reidI have not been able to implement them yet.
Comment #3
dave reidAt 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.
Comment #4
dave reidComment #5
dave reidAfter 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.
Comment #6
dave reidComment #7
dave reidRemoved files from .info.
Comment #8
dave reidFound more CSS, JS, and API functions that can be removed.
Comment #9
mtiftThis 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!
Comment #10
dave reid@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.
Comment #12
dave reidCommitted #8 to 7.x-3.x.
Comment #13
mtiftExcellent! Thanks, Dave!