-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration with music-metadata #606
Conversation
Nice! |
Started using music-metadata to calculate the duration. |
…/*`. The relative URL used for 'Llama DJ Mike Llama' results in a MIME-type: `audio/mpeg; charset=UTF-8`.
# Conflicts: # config/webpack.common.js
I have been exploring this possibility to save size on lazy loading of format specific parses. Therefor I created version of music-metadata in my development environment, with all parsers stripped of except MPEG (for MP3) including required ID3 parsers. In Travis the music-metadata is currently a portion of 240 kb. Which I am for some reason not able to reproduce. If I run Nevertheless, I continued the experiment: what is the difference with just MPEG?. At this point I don't that is worth the effort moving parsers the different library. Maybe trying to exclude bluebird code is more efficient? |
Following analysis is performed by webpack-bundle-analyzer: |
In actual production mode music-metadata is |
js/actionCreators/files.js
Outdated
id | ||
}); | ||
} else { | ||
// ToDo? dispatch(fetchMediaDuration(canonicalUrl, id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there some parsers which can't get duration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there are any, but there maybe specific case that is not possible. Anyway, probably good to make use of the expensive fall back scenario, using the audio element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and we need pass the size of the stream to the parser. The size is critical in some cases to calculate the duration.
@captbaritone#3512 Can you please consider merging music-metadata at this point? I would like to postpone the XHR reader integration. I have checked in the work I have done in that area:
I followed your advice by creating a specialized 'sub-module require' To be honest I am not convinced that the XHR / range based reading is beneficial performance wise in most cases. Most audio tracks have their metadata stored at the beginning of the file. I think the current HTTP to stream based approach, which will be disconnected if the metadata has been read. The only issue I see here is the attempt to read the ID3v1 header which appears at the end of audio tracks. I suggest to create flag to skip that search, if we already have an alternative header. I propose to finalize this pull request with:
|
… headers are searched in a stream. Enable that flag in WebAmp.
This reverts commit 472c2c0.
Sorry that I'm just now getting around to trying this out. Firstly: I'm seeing a number of warnings from Webpack about the SizeThis increases the size of the minified npm library version from 221kb (gzipped) to 292kb (gzipped). At 30% (70kb) jump in the size of this package (which is already pretty huge) seems a bit steep for an incremental improvement. Jsmediatags was 11kb, and you are closer to 80kb when you include the needed polyfills/adapters. Honestly that feels like a hard pill to swallow. Of those 80kb, only 30kb is actually music-metadata code. The rest are node polyfills/adapters, which I'm guessing are probably much more bloated than we really need. Is there anything that can be done to cut this down? Originally I assumed the main weight was due to all the different formats you support, but it looks like your code is actually pretty minimal, especially given the range to formats you support! On Webamp.org we can employ lazy loading to ensure this additional weight does not delay "time to interactive" but in the NPM bundle we can't do lazy loading, so we're pushing this added weight into the critical path. What do you think, are there any other things we can look into to reduce the weight, or does your architecture (based on node streams) mean we just can't expect to get a 30-40kb (gzipped) web version? |
Updated: Problem solved.
It sounds like there is something to gain there. The client side polyfill stuff is not really in my area of expertise. But it sounds like straight forward optimalization me. So if one day the polyfiller would build a bit smarter it could mean we suddenly loose 50kB? |
I did some further analysis to understand where the additional poly-fill space is coming from. I think the 27.05 kB is build like this:
A significant part is caused by the stream-http library, and modules related to streaming. Not sure if that is related to url & from2 as well. |
I have done some basic comparison between:
Since jsmediatags was not able to download any file the numbers the comparison is a bit odd. test executed in debug mode, with full DEBUG logging enabled on music-metadata, using the default WebAmp playlist with the pre-cached metadata disabled.
jsmediatags was not able to download a single file from the default playlist. This is where my skepticism regarding optimization coming from, easy to put focus on details and loosing on the bigger picture. I didn't bother to go into different file types music-metadata covers and jsmediatags does not. This is my last call. I think I demonstrated sufficient support and added value, but I have the feeling you just want to keep things the way they are. |
You've convinced me 😅 I just need to make some changes to Webamp so that I can offer two different bundles. One with music-metadata and jszip included and one where the consumer is required provide a way to lazy load the dependencies. Do you think it would be possible to publish a music-metadata-browser package, or a The advantages which I see:
Also, how much of the stream API do you actually use? If you use less than all of it, maybe we could build a simpler/smaller polyfill which only supports the stuff you need? This is not a blocker for me, but it would be nice to know if there are potential optimizations we could make in the future. Regarding jsmediatags not working on the default files, something about the raw.githubusercontent.com CDN is not working with jsmediatags but is for music metadata. The files work locally and have worked when loaded by URL in the past. In fact, it works for files loaded via the Dropbox integration. I don't know exactly why they are not working from raw.githubusercontent.com. Maybe some kind of CORs issue with headers? Maybe something having to do with range requests? If you feel like investigating, I would be curious to know what it is. |
I do have the ambition to make music-metadata useful for browser apps: Borewit/music-metadata#107, and there are developers who expressed they are looking for that capability. Filtering out the fs module is ugly, it is indeed something which can be improved, at the other hand it works. The lazy loading introduced an issue with d.ts ending up in webpack which has been been fixed in 2.6.0. But before jumping into tweaking the distribution any further, I would like merge the work done first. I think there is also significant work to do in improving the integration between WebAmp and music-metadata, like eliminating loading HTML-audio element with each track to retrieve the duration. Depending if you want to go the async way (#634), a much more granular event mechanism is possible to update stuff. By moving into that direction, without merging it back to the master, the burden on maintaining the branch increases. In addition to that, I would like to have the reality check by people using it, and use there feedback and issues to improve stuff and determine the way ahead. |
Closing in favor of #650. Feel free to reopen if you think there's a good reason to use this PR instead. |
Integeration with music-metadata:
I propose to finalize this pull request with:
Related to: