Skip to content

MSC2448: Using BlurHash as a Placeholder for Matrix Media #2448

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

Open
wants to merge 52 commits into
base: old_master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8ba6071
Add blurhash MSC
anoadragon453 Feb 27, 2020
f71535a
some cleanup
anoadragon453 Feb 27, 2020
8adf2b2
Add blurhash to img tag, make things optional, /upload mod
anoadragon453 Feb 28, 2020
56703fc
unstable prefixes, no encoding needed
anoadragon453 Feb 28, 2020
793107d
Move m.r.m msgtype into the m.r.m section
anoadragon453 Feb 28, 2020
777c30c
hm
anoadragon453 Feb 28, 2020
b80822e
data-mx-blurhash
anoadragon453 Feb 28, 2020
b240d92
Must HTML encode, link to blurhash algo description
anoadragon453 Feb 28, 2020
1afad01
New endpoint, not new key on existing endpoint
anoadragon453 Feb 28, 2020
60773e4
No HTML encoding warning
anoadragon453 Feb 28, 2020
df5b6d7
Straight mxc->blurhash endpoint
anoadragon453 Feb 28, 2020
571ce2a
Unstable feature flag
anoadragon453 Mar 3, 2020
e885eae
blurhash in "info", download->blurhash
anoadragon453 Mar 3, 2020
4b83c51
Merge branch 'anoa/blurhash' of github.com:matrix-org/matrix-doc into…
anoadragon453 Mar 3, 2020
b893c21
Get an image from a blurhash, get a blurhash from an MXC url
anoadragon453 Mar 3, 2020
6e8eb59
Merge branch 'anoa/blurhash' of github.com:matrix-org/matrix-doc into…
anoadragon453 Mar 3, 2020
3695ecf
No GET body
anoadragon453 Mar 3, 2020
842c2a0
Update proposals/2448-blurhash-for-media.md
anoadragon453 Apr 3, 2020
3994010
Explicitly state blurhashes are not exempt from encryption
anoadragon453 Aug 18, 2020
616bc81
/upload -> xyz.amorgan.blurhash instead
anoadragon453 Aug 18, 2020
e0a7442
Add blurhashes to URL previews
anoadragon453 Jan 26, 2021
385be8a
Clarify that 'blurhash' should go in content.info
anoadragon453 Jan 26, 2021
708b756
formatting
anoadragon453 Jan 26, 2021
b761b06
Add blurhash to m.sticker events
anoadragon453 Jan 26, 2021
40d71ff
Add m.room.member
anoadragon453 Jan 26, 2021
7f13184
Add m.room.avatar
anoadragon453 Jan 26, 2021
1300a6e
Update unstable prefixes section for new event types
anoadragon453 Jan 26, 2021
2a02d2c
Specify endpoints that will need to be modified to support avatar blu…
anoadragon453 Jan 26, 2021
7ea82b4
Remove the controversial /_matrix/media/r0/blurhash endpoint
anoadragon453 Jan 26, 2021
f93d708
Format the Unstable prefixes section a little more nicely
anoadragon453 Jan 26, 2021
ed9ed5e
grammar
anoadragon453 Jan 26, 2021
48c4d55
Add a quick note about encrypted media and server-side blurhash calc
anoadragon453 Jan 26, 2021
fba60db
Rename with a more generic title
anoadragon453 Jan 26, 2021
c837c83
Riot -> Element
anoadragon453 Jan 26, 2021
b3f1915
Slight title adjustment
anoadragon453 Jan 26, 2021
5b8c191
Add note about negligible DoS potential of large blurhashes
anoadragon453 Jan 26, 2021
63d4966
Add note about invalid BlurHashes
anoadragon453 Jan 26, 2021
676571f
Move blurhash to m.room.avatar's content.info dict
anoadragon453 Apr 1, 2021
a302197
Merge branch 'master' of github.com:matrix-org/matrix-doc into anoa/b…
anoadragon453 Apr 1, 2021
594bcee
Apply suggestions from code review
anoadragon453 Apr 13, 2021
64116ae
Clarify that clients must calculate blurhashes for encrypted media
anoadragon453 Apr 13, 2021
9bd0ba6
Fix inconsistency of blurhashes MUST vs SHOULD be omitted
anoadragon453 May 22, 2021
e7e0fb7
blurhashes can be inserted into more than just m.room.message events
anoadragon453 May 22, 2021
1d954f0
Remove the need for an unstable_features entry
anoadragon453 May 22, 2021
9e981ba
Make blurhash generation on the server opt-in
anoadragon453 May 22, 2021
75a4fa6
Clarify why we place blurhash under the matrix:image:blurhash OG prop
anoadragon453 May 22, 2021
934b6d7
Mention that the generate_blurhash query param needs an unstable prefix
anoadragon453 May 22, 2021
974d368
lint proposal markdown
anoadragon453 Aug 1, 2022
5668397
Apply suggestions from TravisR
anoadragon453 Aug 1, 2022
234877c
Clear client recommendations for blurhashes vs. thumbnails
anoadragon453 Aug 1, 2022
abf5283
r0 -> v3; update links to new spec website
anoadragon453 Aug 1, 2022
754fa7a
Add and update request/repsonse examples
anoadragon453 Aug 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Straight mxc->blurhash endpoint
  • Loading branch information
anoadragon453 committed Feb 28, 2020
commit df5b6d7260a9d70890efe5234c6a326afc666f4a
23 changes: 23 additions & 0 deletions proposals/2448-blurhash-for-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ Example response:
}
```

In addition, a new endpoint will be added to the Media API that allows a
client with an existing mxc URL to retrieve a blurhash for it from the
server. It will take the form of `GET
/_matrix/media/r0/download/{serverName}/{mediaId}/blurhash`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please not download, as blurhash is a valid file name. Ideally this would show up in #2380 not here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, poor shape choice.

Would you be happy with a temporary API for this in the meantime until #2380 lands?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about GET /_matrix/media/r0/blurhash/{serverName}/{mediaId} instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather we pushed 2380 through tbh

All this MSC needs to do is say "also MSC2380, or similar, will have a blurhash property`. A dedicated endpoint for such a value is not great.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, yeah that could be useful, though if a client doesn't support it then is having the server render it and then send it down any different from pulling down a thumbnail?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I misread your comment. So you're suggesting hold off on having the server provide a dedicated blurhash endpoint in favour of MSC2380. That sounds fair, and will just mean clients will need to compute it in implementation for now.

Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, one issue with using MSC2380, and not a dedicated endpoint, is that clients won't be able to specify the X/Y parameters of the resolution of the blurhash (or you could, but adding blurhash-specific parameters to /info seems a bit weird).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think not being able to specify the blurhash components is a major issue. You need to know the image anyway, to specify those parameters, so it is probably best if the media repo does that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea the thing generating the blurhash would know the components and the components can be pulled out of the blurhash. I don't think we really need a way to specify the components as that actually adds overhead (the media repo then has to decide if it cares, and possibly recalculate it).

MSC2380 is just to return a bunch of stuff about an uploaded file, such as the blurhash. A separate download endpoint (which takes a blurhash string) could render whatever it was given faster than trying to deal with thumbnailing. Separately to both of those, the upload endpoint could maybe take X and Y components, but I'd personally be inclined to just ignore those in my implementation because uploading something is already hard enough on the server.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so no component specification.

I've updated the doc. Let me know if we're on the same page?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A different option might be /_matrix/media/r0/blurhash/{encodedBlurhash}?width=512&height=512 which forces the server to render it instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of like that idea, though it could be a potential exploit vector if there was a vuln in the blurhash library implementation, and maybe a DOS vector if you give it a really big blurhash string.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, ok, #2448 (comment) should've ended up in this thread. Repeating it here instead:

Huh, yeah that could be useful, though if a client doesn't support it then is having the server render it and then send it down any different from pulling down a thumbnail?

Basically I'm happy to have an endpoint for returning the blurhash string from an mxc URL, though not sure about an image from a blurhash string, due to potential attack vectors and that downloading a blurhash as an image would probably not be much faster than downloading the thumbnail itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've decided to go for the extra endpoint. See #2448 (comment).


Example request:

```
GET /_matrix/media/r0/download/example.com/abcde12345/blurhash
```

Example response:

```
{
"blurhash": "LEHV6nWB2yk8pyo"
}
```

## Visualisation

Viewing an image message that is loading:
Expand Down Expand Up @@ -133,6 +152,10 @@ The `blurhash` key in `m.room.message` should be replaced with
`/_matrix/media/unstable/xyz.amorgan/upload`, which keeps the same `blurhash`
response key.

`/_matrix/media/r0/download/{serverName}/{mediaId}/blurhash` should be
replaced with
`/_matrix/media/unstable/xyz.amorgan/download/{serverName}/{mediaId}/blurhash`.

The `data-mx-blurhash` attribute in `<img>` tags should be replaced with
`data-xyz-amorgan-blurhash`.

Expand Down