Page MenuHomePhabricator

Precision of floating-point video length is inconsistent between HHVM and PHP 7.2
Closed, ResolvedPublicBUG REPORT

Description

Steps to Reproduce:

Actual Results:

Expected Results:

  • The value is reported with the same precision across requests and is consistent with the precision when requesting from the file's native repo

Event Timeline

Mholloway created this task.Aug 9 2019, 4:44 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 9 2019, 4:44 AM
Mholloway updated the task description. (Show Details)Aug 9 2019, 1:13 PM
Mholloway renamed this task from Rounding of video length is inconsistent when requested from a foreign file repo to Precision of floating-point video length is inconsistent when requested from a foreign file repo.Aug 9 2019, 5:52 PM
Mholloway updated the task description. (Show Details)
Mholloway triaged this task as Lowest priority.EditedAug 9 2019, 5:54 PM

This really isn't important but I'm very curious about what's going on.

I can imagine it has something to do with different processors in use across the fleet of mw* hosts, but then it doesn't make sense why the inconsistency would only show up when requesting from a foreign as opposed to a local file repo.

brion added a subscriber: brion.Aug 9 2019, 7:04 PM

I can repro the inconsistency on both domains. I think it's a HHVM vs Zend PHP difference; the shorter serialization is served from HHVM 3.18.6 while the longer one is served from PHP 7.2.16.

Mholloway closed this task as Resolved.Aug 9 2019, 7:15 PM
Mholloway claimed this task.

Makes sense. Now that you mention it, I see that the PHP 7.2 rollout is still very much in progress. Weird that I didn't get the shorter version from Commons at least once, though. Thanks for looking into it :)

TheDJ added a subscriber: TheDJ.Aug 12 2019, 5:25 PM

Shouldnt we trim to a sane amount of digits behind the radix ???

.000 seems plenty of precision to me.

brion added a comment.Aug 12 2019, 7:57 PM

Would you want to trim in the base handling of the metadata, or in the output API serialization specifically? Might be best to do it all around if we're going to apply such rounding in ways that are machine-readable.

Could perhaps do this in ID3Handler::getLength(), just wrap that $metadata['playtime_seconds'] in a round( $length, 3 ) or something. Not really a big deal either way I think though.

(Note that different formats have different time resolutions; WebM usually has millisecond resolution for the time scale, while Ogg files have a fixed frame rate for video or sampling rate for audio which may be any rational fraction. WAV files are sample-based, and MP3 has small blocks and I don't know if it can represent exact lengths. So it's all fun and exciting! Middleware like the GetID3 library often hides this complexity and gives you a nice floating point number with some random precision you can't predict or introspect. Awesome.)

Mholloway renamed this task from Precision of floating-point video length is inconsistent when requested from a foreign file repo to Precision of floating-point video length is inconsistent between HHVM and PHP 7.2.Aug 13 2019, 1:42 PM