little-bear-labs / ipfs-chromium

19 stars 1 forks source link

Bug(v0.0.0.2): .webm video play crash on linux #31

Closed lidel closed 1 year ago

lidel commented 1 year ago

When I try to play ipfs://bafybeieb33pqideyl5ncd33kho622thym5rqv6sujrmelcuhkjlf2hdpu4/Big%20Buck%20Bunny.webm the browser hangs, does not react to any UI input nor does redraw.

Playing the same video from https://dweb.link/ipfs/bafybeieb33pqideyl5ncd33kho622thym5rqv6sujrmelcuhkjlf2hdpu4/Big%20Buck%20Bunny.webm works ok.

I tested prebuilt v0.0.0.2 for Linux (RPM) (rpm2tar chromium-browser-unstable-113.0.5672.126-1.x86_64.rpm)

John-LittleBearLabs commented 1 year ago

It "worked" for me. I entered the URL, left, came back and it showed the loading thing turning, did some other work for a while, and eventually sound started coming out. I switched back and indeed the video was playing.

I wonder if this is less of a crash and more like unacceptably terrible performance.

whizzzkid commented 1 year ago

It crashed on my m1 mac, never saw what's in the video.

John-LittleBearLabs commented 1 year ago

So I'm not sure I'm investigating the same issue you have both seen, because it's never crashed for me. It froze and my desktop environment (GNOME) complained about it being unresponsive and prompted me for whether I'd like to wait or "Force Quit", but if I let it sit for an insanely long time it'll eventually work. In a release build that seems to be somewhere in the neighborhood of 5-10 minutes, in a debug build 1-2 hours.

I was assuming this was a problem with the number of round trips on the network (several hundred modestly-sized requests instead of 1 large one from dweb.link). Shockingly, that's not where the overwhelming majority of the time is going. The headers that are being placed in there for debugging in devtools, each one takes longer than the previous one to be added to the metadata, and it gets to completely absurd levels because in this setup there's a separate few headers for each CID in the DAG that was resolved in the process of dealing with this URL. In this case that's: 1 for the directory at the root CID bafybeieb33pqideyl5ncd33kho622thym5rqv6sujrmelcuhkjlf2hdpu4 1 for the root of the file (linked to by the directory) QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T 4 for the top-level links of that file (Qmefro9w9tV2RNcqvEEWpeQh4puYfBRhG6pUe3UfquL8uU...) 813 links from those 4 (QmbHVkhGs8dTgdSvBsjc73TqKQoiLLQb3eqiqdXrykqD3J...)

I watched until those headers were taking 3 seconds a piece, which is insane, but it was still getting worse.

I tried an experiment of limiting the number of "Server-Timing", "Block-Source", and "ZZZ-" headers to those dealing with the first 9 CIDs max. Then the release build loads the video and starts playing it in 2-3 seconds.

Do y'all think it's OK to just "solve" it like that, or should I do something different like track the total count of CIDs and include something like "+ 810 more CIDs"?

lidel commented 1 year ago

@John-LittleBearLabs as discussed on call today, let's remove DoS vector and stop setting these debug-level headers for every block, make the headers cumulative.

Would below be possible?

Together, these will allow pretty good visibility into performance across gateways, one will be able to spot underperforming one, but without going into full debug mode.

John-LittleBearLabs commented 1 year ago

I do fear people will look at these sums of timings and think they happened sequentially. The issue with that can be clearly seen in this screenshot.

image

The total time is 21 seconds, yet 4.4 minutes was spent fetching 88 blocks from that one gateway. Because, naturally, multiple requests were sent to that gateway in parallel.

lidel commented 1 year ago

@John-LittleBearLabs Ack, this looks pretty confusing, especially with the info is cut by devtools anyway.

Maybe just keep "til the first block" in Server-Timing (and rename it to shorter first block from {gateway-host}) and move totals out?

To make it easier to eyebald, would it be possible to add one Ipfs-Block-Sources per gateway?

# Ipfs-Block-Sources: {gateway-host-a}`;blocks={count};bytes={bytes};cdur={ms-cummulative}
Ipfs-Block-Sources: {gateway-host-a};blocks=2;bytes=4563;dur=10340
Ipfs-Block-Sources: {gateway-host-b};blocks=1;bytes=42;dur=1053
John-LittleBearLabs commented 1 year ago

Seems somewhat workable to me for now. There's a bunch of devtools enhancements slated for phase 2. image image