Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 30 additions & 0 deletions .github/workflows/prototype-prerender.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: prototype prerender tests

on:
push:
branches:
- prototype-stupid-prerenderers
pull_request:
paths:
- 'prototype/**'
- '.github/workflows/prototype-prerender.yml'
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run reference pre-renderer tests
run: python3 prototype/test_prerender.py
- name: Generate sample first paint
run: |
python3 prototype/prerender.py prototype/example.html \
--source https://example.test/ \
--out preview-out
ls -lh preview-out
- name: Retain sample preview
uses: actions/upload-artifact@v4
with:
name: stupid-prerender-sample
path: preview-out/
2 changes: 2 additions & 0 deletions prototype/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
preview-out/
*.pbm
12 changes: 12 additions & 0 deletions prototype/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Notes

This prototype is intentionally stupid.

It exists to answer four questions before ib chooses its implementation language or real renderer:

1. Can first paint be produced from browser-owned bytes without starting a full renderer?
2. Can the first paint stay small enough to cache for many sleeping tabs?
3. Can previews be deleted and regenerated without changing durable browsing state?
4. Can the UI progressively ask for metadata, text, one visual screen, more visual screens, and finally a live renderer instead of loading everything at once?

The answer should remain yes even if this Python prototype is thrown away completely.
32 changes: 32 additions & 0 deletions prototype/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Deliberately stupid pre-renderers

This directory is an executable design probe for the browser-core/renderer boundary. It is not a choice of implementation language and it is not intended to grow into the real renderer.

`prerender.py` accepts already-fetched HTML and emits two disposable forms of first paint:

- `preview.txt`: title, source URL/label, and visible-ish text, capped at 8 KiB by default.
- `screen-01.pbm` through `screen-03.pbm`: at most three 180×320 one-bit rough visual previews. Each default PBM is about 7.2 KiB.

The bitmap preview is deliberately not a screenshot of a fully rendered web page. It ignores CSS, JavaScript, images, fonts, layout, forms, media, and subresources. It rasterizes extracted text with a tiny built-in 5×7 font. Its purpose is to test whether ib can show something recognizable immediately while the real renderer is absent, sleeping, loading, crashed, or being replaced.

## Try it

```sh
python3 prototype/prerender.py page.html \
--source https://example.org/ \
--out /tmp/ib-preview
```

The input may also be piped on stdin by using `-` as the input path.

## Tests

```sh
python3 prototype/test_prerender.py
```

The tests check that scripts/styles are excluded, text output remains bounded, visual previews stay below 8 KiB per default screen, and visual output is capped at three screens.

## Architectural rule being tested

A pre-renderer consumes browser-owned fetched/snapshot material and produces a disposable preview. Neither `preview.txt` nor the PBM files are canonical browsing state. Deleting all of them must not delete a tab, a history entry, a snapshot, or user organization.
21 changes: 21 additions & 0 deletions prototype/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>IB pre-renderer example</title>
<style>body { color: red; }</style>
</head>
<body>
<h1>This appears before the real renderer</h1>
<p>The text preview is intentionally boring. It exists so a sleeping tab can show recognizable content without waking Chromium, Servo, WebView, or anything else.</p>
<p>The bitmap version is only a tiny monochrome approximation of this text. A real renderer may replace it whenever it becomes available.</p>
<script>throw new Error('a pre-renderer must not execute me');</script>
<h2>Second screen material</h2>
<p>This paragraph is repeated to make scrolling through a rough preview meaningful. The preview can contain one, two, or three phone-sized images and no more.</p>
<p>This paragraph is repeated to make scrolling through a rough preview meaningful. The preview can contain one, two, or three phone-sized images and no more.</p>
<p>This paragraph is repeated to make scrolling through a rough preview meaningful. The preview can contain one, two, or three phone-sized images and no more.</p>
<p>This paragraph is repeated to make scrolling through a rough preview meaningful. The preview can contain one, two, or three phone-sized images and no more.</p>
<p>This paragraph is repeated to make scrolling through a rough preview meaningful. The preview can contain one, two, or three phone-sized images and no more.</p>
<p>This paragraph is repeated to make scrolling through a rough preview meaningful. The preview can contain one, two, or three phone-sized images and no more.</p>
</body>
</html>
Loading
Loading