forge
Explore
Log in

Don't you dare go Hollow

The window is up before the film is read, and says which film

Browse files at this commit

544d97b8eef72f0bac863c453d8602f97a000df5Ahmet Kaan GümüşParent: 95fb78d
  • perf
    • the window is up before the film is read, and says which film
Show full message
⚡ perf(launch): the window is up before the film is read, and says which film

`edith <25 GB film>` on a cold cache showed nothing at all for twelve
seconds: the window was only created after argv[1] had been opened, and a
window that does not exist cannot say what it is waiting for.

argv is now sorted, not read: every file it names -- the first one included
-- goes into the queue a drop uses, and the window comes up empty in 47 ms
with the file's name in the title and an OPENING line under the panel
naming the read that is running. The first file is the one queued file that
is not an import, so its worker *opens* it outright and hands the session
over whole (`open_ahead` -> `Landed::Media`/`Project` -> `install_media`/
`install_project`), which is also what keeps a warm launch paying for one
header walk instead of two. Everything derived from the file -- canvas, fps,
title, export and save paths, subtitle tracks -- is set where it always was,
one repaint later; a refused file now says OPEN FAILED in the notice bar
instead of exiting before the window.

Measured (harness, timestamped sway-IPC + app log): cold 29.6 GB remux,
exec -> window 12.95 s / 18.73 s -> 0.047 s, exec -> timeline unchanged
(12.9 s -> 12.8 s); warm 2.9 GB film, window 0.73 s -> 0.048 s, timeline
0.68 s -> 0.71 s. The window resizes and repaints throughout the read.
crates/app/src/main.rsmodified+321 -120
@@ -1189,6 +1189,14 @@ struct Player {
11891189 /// this holds is the line above the panel ([`Player::import_bar`]).
11901190 importing: Option<Import>,
11911191 imports: std::collections::VecDeque<PathBuf>,
1192+ /// The file argv named, until its read lands. It goes through the queue
1193+ /// above like any other file -- that is what puts the window on screen
1194+ /// before a byte of a 25 GB film is read -- and this is what tells
1195+ /// [`Player::take_import`] that this one is an *open* and not an import:
1196+ /// it becomes the timeline, and the clock, the title and the export path
1197+ /// come from it. Cleared the moment it lands, so a later drop of the very
1198+ /// same path is an import like any other.
1199+ opening: Option<PathBuf>,
11921200 /// Where an export writes. Built once from the source path, which is not
11931201 /// otherwise kept.
11941202 export_path: PathBuf,
@@ -3923,9 +3931,16 @@ impl Player {
39233931 return;
39243932 };
39253933 let stage = Arc::new(std::sync::atomic::AtomicU8::new(ImportStage::Header as u8));
3934+ // The fork is made here, once, and carried to the landing: an import is
3935+ // *read* on the worker and opened again warm, while the file argv named
3936+ // is *opened* on the worker and handed over whole. Both leave the UI
3937+ // thread free for the twelve seconds a cold 25 GB header walk takes;
3938+ // opening the timeline outright is what keeps it from paying the walk
3939+ // twice on a warm one.
3940+ let what = arrival(self.opening.as_deref(), &path);
39263941 let read = cx.background_executor().spawn({
39273942 let (path, stage) = (path.clone(), Arc::clone(&stage));
3928- async move { read_ahead(&path, &stage) }
3943+ async move { open_ahead(what, &path, &stage) }
39293944 });
39303945 let now = Instant::now();
39313946 self.importing = Some(Import {
@@ -3936,10 +3951,10 @@ impl Player {
39363951 since: now,
39373952 });
39383953 cx.spawn(async move |this, cx| {
3939- read.await;
3954+ let landed = read.await;
39403955 this.update(cx, |this, cx| {
39413956 this.importing = None;
3942- this.take_import(&path, cx);
3957+ this.take_import(&path, landed, cx);
39433958 // The next one is started by the repaint this notified, which
39443959 // is also what starts the files argv named ([`poll_import`]).
39453960 })
@@ -3974,10 +3989,45 @@ impl Player {
39743989 /// The export guard again, and not for the caller's sake: an export can
39753990 /// have started during the seconds the worker was reading, and a drop
39763991 /// during an export has always been a silent no-op.
3977- fn take_import(&mut self, path: &std::path::Path, cx: &mut Context<Self>) {
3992+ fn take_import(&mut self, path: &std::path::Path, landed: Landed, cx: &mut Context<Self>) {
39783993 if self.exporting().is_some() {
39793994 return;
39803995 }
3996+ // The file argv named is the one file in the queue that is not an
3997+ // import: it *is* the timeline, and the worker has already opened it.
3998+ // All that is left here is to hang everything derived from it off the
3999+ // window -- the clock, the title, where an export and a save go -- and
4000+ // that is arithmetic, not a read.
4001+ match landed {
4002+ Landed::Read => {}
4003+ what => {
4004+ self.opening = None;
4005+ match what {
4006+ Landed::Project(opened) => self.install_project(path, opened, cx),
4007+ Landed::Media(opened) => {
4008+ let text = self.install_media(path, opened, true);
4009+ eprintln!("{text}");
4010+ self.notice = Some(text.into());
4011+ cx.notify();
4012+ }
4013+ Landed::Read => unreachable!("matched above"),
4014+ }
4015+ // The line a launch has always printed, now printed when the
4016+ // file actually arrives: it is the mark that says the timeline
4017+ // is up, as the window's own appearance is the other one.
4018+ if let Some(meta) = self.session.as_ref().map(PlaybackSession::meta) {
4019+ println!(
4020+ "{}: {}x{} @ {:.2} fps, {} samples",
4021+ path.display(),
4022+ meta.width,
4023+ meta.height,
4024+ meta.frame_rate,
4025+ meta.frame_count
4026+ );
4027+ }
4028+ return;
4029+ }
4030+ }
39814031 // An empty window has no library to add to yet: the file opens one, and
39824032 // the timeline under it stays empty, because an import is an import
39834033 // whether or not a session was already up. A file *named at launch* is
@@ -4042,19 +4092,26 @@ impl Player {
40424092 /// *opened* is the timeline, one *imported* into an empty window fills the
40434093 /// library and leaves the lanes empty for a drag.
40444094 fn open_media(&mut self, path: &std::path::Path, place: bool) -> String {
4045- let opened = match place {
4046- true => PlaybackSession::open(path),
4047- false => PlaybackSession::open_library(path),
4048- };
4095+ self.install_media(path, open_session(path, place), place)
4096+ }
4097+
4098+ /// The second half of it: everything the window derives from a session that
4099+ /// has already been opened. Split from the open itself because the file
4100+ /// argv named is opened on a worker ([`open_ahead`]) -- the twelve seconds
4101+ /// of a cold header walk are not the UI thread's to spend -- and lands
4102+ /// here, where nothing is read and nothing blocks.
4103+ fn install_media(
4104+ &mut self,
4105+ path: &std::path::Path,
4106+ opened: Result<(PlaybackSession, String), String>,
4107+ place: bool,
4108+ ) -> String {
40494109 match opened {
4050- Ok(mut session) => {
4110+ Ok((session, subs)) => {
40514111 self.fps = session.meta().frame_rate;
40524112 // Read before the session moves: a file that plays silent says
40534113 // so here or nowhere.
40544114 let silent = audio_notice(&session);
4055- // ...and the subtitle tracks the file carries inside it, taken
4056- // now: nothing else ever opens this container again.
4057- let subs = subtitle_notice(&mut session, path).unwrap_or_default();
40584115 // A file replaces the one that was open, and track 3 of that one
40594116 // is not track 3 of this.
40604117 self.sub_track = 0;
@@ -4117,10 +4174,23 @@ impl Player {
41174174 /// The new session is built before anything is replaced, so a refusal is
41184175 /// shown as the engine worded it and leaves what is playing alone.
41194176 fn load_project(&mut self, path: &std::path::Path, cx: &mut Context<Self>) {
4177+ let opened = PlaybackSession::open_project(path).map_err(|e| e.to_string());
4178+ self.install_project(path, opened, cx);
4179+ }
4180+
4181+ /// The second half of it, for [`Player::install_media`]'s reason: a
4182+ /// `.edith` named on the command line is opened on a worker and only
4183+ /// installed here.
4184+ fn install_project(
4185+ &mut self,
4186+ path: &std::path::Path,
4187+ opened: Result<PlaybackSession, String>,
4188+ cx: &mut Context<Self>,
4189+ ) {
41204190 if self.exporting().is_some() {
41214191 return;
41224192 }
4123- let text = match PlaybackSession::open_project(path) {
4193+ let text = match opened {
41244194 Ok(session) => {
41254195 self.fps = session.meta().frame_rate;
41264196 let silent = audio_notice(&session);
@@ -6631,6 +6701,7 @@ impl Player {
66316701 elapsed,
66326702 import.since.elapsed().as_secs_f32(),
66336703 self.imports.len(),
6704+ arrival(self.opening.as_deref(), &import.path) != Landing::Import,
66346705 );
66356706 // A quarter of the bar, crossing it every three seconds and wrapping.
66366707 // Tied to the elapsed clock, so it moves for as long as the read does
@@ -9994,6 +10065,68 @@ fn is_matroska(path: &std::path::Path) -> bool {
999410065 .is_some_and(|e| matches!(e.to_ascii_lowercase().as_str(), "mkv" | "webm"))
999510066 }
999610067
10068+/// What a worker hands back, which is the fork [`arrival`] made when it was
10069+/// started. An import is *read* and thrown away; the file argv named is opened
10070+/// outright, because nothing else is going to open it afterwards.
10071+enum Landed {
10072+ /// An import: pages warmed, nothing kept. [`Player::take_import`] opens the
10073+ /// file again, warm, and that second open is the 150 ms one.
10074+ Read,
10075+ /// The media argv named, with the tail its subtitle tracks earn: a whole
10076+ /// timeline, ready to be hung off the window, or the engine's refusal.
10077+ Media(Result<(PlaybackSession, String), String>),
10078+ /// The `.edith` argv named, restored.
10079+ Project(Result<PlaybackSession, String>),
10080+}
10081+
10082+/// A media file opened as a session, with the subtitle tracks it carries inside
10083+/// it taken in the same breath -- the two reads a file costs, in the one place
10084+/// both doors ([`Player::open_media`] and the worker below) go through.
10085+///
10086+/// `place` is which door: a file *opened* is the timeline, one *imported* into
10087+/// an empty window fills the library and leaves the lanes empty for a drag.
10088+fn open_session(path: &std::path::Path, place: bool) -> Result<(PlaybackSession, String), String> {
10089+ let opened = match place {
10090+ true => PlaybackSession::open(path),
10091+ false => PlaybackSession::open_library(path),
10092+ };
10093+ let mut session = opened.map_err(|e| e.to_string())?;
10094+ let subs = subtitle_notice(&mut session, path).unwrap_or_default();
10095+ Ok((session, subs))
10096+}
10097+
10098+/// The whole of what a queued file costs, off the UI thread. An import only
10099+/// needs its pages warmed ([`read_ahead`]); the file argv named is *opened*
10100+/// here instead, and that is the difference between a warm launch paying for
10101+/// one header walk and paying for two -- the window is up either way.
10102+fn open_ahead(
10103+ what: Landing,
10104+ path: &std::path::Path,
10105+ stage: &std::sync::atomic::AtomicU8,
10106+) -> Landed {
10107+ use std::sync::atomic::Ordering::Relaxed;
10108+ match what {
10109+ Landing::Import => {
10110+ read_ahead(path, stage);
10111+ Landed::Read
10112+ }
10113+ Landing::Project => {
10114+ let opened = PlaybackSession::open_project(path).map_err(|e| e.to_string());
10115+ Landed::Project(opened)
10116+ }
10117+ Landing::Open => {
10118+ let opened = PlaybackSession::open(path).map_err(|e| e.to_string());
10119+ // The same two stages a read reports, because they are the same two
10120+ // reads: the container, and then the tracks inside it.
10121+ stage.store(ImportStage::Subtitles as u8, Relaxed);
10122+ Landed::Media(opened.map(|mut session| {
10123+ let subs = subtitle_notice(&mut session, path).unwrap_or_default();
10124+ (session, subs)
10125+ }))
10126+ }
10127+ }
10128+}
10129+
999710130 /// Reads, off the UI thread, exactly what the import that follows is about to
999810131 /// read -- and throws every byte away. The point is the page cache: a cold
999910132 /// header walk of a 29 GB remux is 11 s and a warm one is 150 ms (measured,
@@ -10042,8 +10175,9 @@ fn read_ahead(path: &std::path::Path, stage: &std::sync::atomic::AtomicU8) {
1004210175 /// The walk reads the whole file for its cues
1004310176 /// (`engine::subtitle::of_matroska`) -- ~200 ms on a two-hour 4K remux, and an
1004410177 /// *import* pays it on a worker first ([`read_ahead`]), so what happens here is
10045-/// the warm second pass. A file *opened* at launch still pays it cold: there is
10046-/// no window yet to say so in.
10178+/// the warm second pass. A file *opened* at launch pays it cold and pays it
10179+/// once -- this runs on the worker beside the open itself ([`open_ahead`]),
10180+/// with the window already up and naming the read.
1004710181 fn subtitle_notice(session: &mut PlaybackSession, path: &std::path::Path) -> Option<String> {
1004810182 if !is_matroska(path) {
1004910183 return None;
@@ -12848,6 +12982,44 @@ impl ImportStage {
1284812982 }
1284912983 }
1285012984
12985+/// argv sorted into the file that becomes the timeline and the queue every
12986+/// named file is read through, in the order they were named. The whole of what
12987+/// a launch does before the window is on screen -- and it touches no disk,
12988+/// which is the point: the header walk happens on a worker with the window
12989+/// already up ([`Player::take_import`]).
12990+fn launch_queue(
12991+ args: impl Iterator<Item = PathBuf>,
12992+) -> (Option<PathBuf>, std::collections::VecDeque<PathBuf>) {
12993+ let queue: std::collections::VecDeque<PathBuf> = args.collect();
12994+ (queue.front().cloned(), queue)
12995+}
12996+
12997+/// What a queued file turns into. Every file goes through one queue -- argv's
12998+/// first file, argv's extras, a drop, the Import button -- and this is the fork
12999+/// its worker is started on.
13000+#[derive(PartialEq, Eq, Debug, Clone, Copy)]
13001+enum Landing {
13002+ /// The media argv named: it becomes the timeline, and the canvas, the fps,
13003+ /// the title and the export path come from it.
13004+ Open,
13005+ /// A `.edith` argv named: a whole timeline restored, not a source.
13006+ Project,
13007+ /// Everything else: a row in the library, the timeline untouched.
13008+ Import,
13009+}
13010+
13011+/// Which of the three a queued file is (`landing` above is the drag's).
13012+/// `opening` is the one path argv named and is cleared as it lands, so a second
13013+/// arrival of the same path -- a drop of the film that is already open -- is an
13014+/// import, which is what a drop has always been.
13015+fn arrival(opening: Option<&std::path::Path>, path: &std::path::Path) -> Landing {
13016+ match opening == Some(path) {
13017+ false => Landing::Import,
13018+ true if is_project(path) => Landing::Project,
13019+ true => Landing::Open,
13020+ }
13021+}
13022+
1285113023 /// The whole of what an import shows while it runs: which file, which stage,
1285213024 /// the clock that proves the window is still answering, and what is behind it
1285313025 /// in the queue.
@@ -12855,19 +13027,35 @@ impl ImportStage {
1285513027 /// `since` is how long the *stage* has stood still, which is the only movement
1285613028 /// an unmeasurable read has: past [`IMPORT_STALL`] the line says so in words,
1285713029 /// because a bar that cannot move and a bar that has stopped look identical.
12858-fn import_line(name: &str, stage: ImportStage, elapsed: f32, since: f32, waiting: usize) -> String {
13030+///
13031+/// `opening` is the file argv named, which is read through the same queue and
13032+/// says so in the same words -- except that it is being *opened*, and a line
13033+/// that called it an import would be describing the wrong thing to the one
13034+/// person who typed the name.
13035+fn import_line(
13036+ name: &str,
13037+ stage: ImportStage,
13038+ elapsed: f32,
13039+ since: f32,
13040+ waiting: usize,
13041+ opening: bool,
13042+) -> String {
1285913043 let tail = match waiting {
1286013044 0 => String::new(),
1286113045 n => format!(" · {n} more waiting"),
1286213046 };
1286313047 let what = stage.what();
13048+ let verb = match opening {
13049+ true => "OPENING",
13050+ false => "IMPORTING",
13051+ };
1286413052 match since >= IMPORT_STALL {
1286513053 true => format!(
12866- "IMPORTING {name} · still {what} — a big file is minutes of reading, and the window is \
13054+ "{verb} {name} · still {what} — a big file is minutes of reading, and the window is \
1286713055 not frozen · {} elapsed{tail}",
1286813056 clock(elapsed)
1286913057 ),
12870- false => format!("IMPORTING {name} · {what} · {} elapsed{tail}", clock(elapsed)),
13058+ false => format!("{verb} {name} · {what} · {} elapsed{tail}", clock(elapsed)),
1287113059 }
1287213060 }
1287313061
@@ -12997,6 +13185,7 @@ mod tests {
1299713185 fit_choices, landing, lane_refuses, library_rows, live_idx, next_fit, next_resolution,
1299813186 note_progress, px_along,
1299913187 IMPORT_STALL, Import, ImportStage, SEEK_STALL, ScanPlan, SilenceScan, import_line,
13188+ Landing, arrival, launch_queue,
1300013189 read_ahead, scan_plan, seek_line, silence_line, stash_or_write,
1300113190 repeats, resolution_choices, resolution_ladder, span_label, tone_choices, tone_label,
1300213191 trimmed_clip, unscannable,
@@ -16267,7 +16456,7 @@ mod tests {
1626716456 // the line stops pretending it is a progress line.
1626816457 let since = import.poll();
1626916458 assert!(since > IMPORT_STALL, "{since}");
16270- let stalled = import_line("A Film.mkv", import.seen, 9., since, 0);
16459+ let stalled = import_line("A Film.mkv", import.seen, 9., since, 0, false);
1627116460 assert!(stalled.contains("still reading the header"), "{stalled}");
1627216461 assert!(stalled.contains("not frozen"), "{stalled}");
1627316462 assert!(stalled.contains("0:09 elapsed"), "{stalled}");
@@ -16277,7 +16466,7 @@ mod tests {
1627716466 let since = import.poll();
1627816467 assert_eq!(import.seen, ImportStage::Subtitles);
1627916468 assert!(since < IMPORT_STALL, "{since}");
16280- let moving = import_line("A Film.mkv", import.seen, 9., since, 2);
16469+ let moving = import_line("A Film.mkv", import.seen, 9., since, 2, false);
1628116470 assert!(
1628216471 moving.starts_with("IMPORTING A Film.mkv · reading the subtitle tracks"),
1628316472 "{moving}"
@@ -16294,6 +16483,74 @@ mod tests {
1629416483 assert_eq!(import.since, held, "an unchanged stage must not reset it");
1629516484 }
1629616485
16486+ /// The launch, from argv to the window being up: nothing named on the
16487+ /// command line is read before there is a window, so all a launch does is
16488+ /// sort argv into the file that becomes the timeline and the queue that is
16489+ /// read through -- and a run with no arguments has neither, exactly as it
16490+ /// had none before.
16491+ #[test]
16492+ fn a_launch_queues_the_file_it_names_instead_of_opening_it() {
16493+ let film = PathBuf::from("/films/Dune.mkv");
16494+ let extra = PathBuf::from("/films/Titles.mov");
16495+ let (arg, queue) = launch_queue([film.clone(), extra.clone()].into_iter());
16496+ assert_eq!(arg.as_deref(), Some(film.as_path()), "argv[1] is the open");
16497+ // In the order they were named, the timeline's file first: six header
16498+ // walks racing over one disk finish no sooner than six in a row, and
16499+ // the one the person is waiting to watch goes first.
16500+ assert_eq!(queue, [film, extra], "argv, in arrival order");
16501+ // ...and no argument at all is still the empty window: nothing to open
16502+ // and nothing to read.
16503+ let (arg, queue) = launch_queue(std::iter::empty());
16504+ assert_eq!(arg, None);
16505+ assert!(queue.is_empty(), "no argv, nothing queued");
16506+ }
16507+
16508+ /// Which door a queued file goes through. One queue carries the file argv
16509+ /// named and every import behind it, so this fork -- made when the worker
16510+ /// starts and carried to the landing as a [`Landed`] -- is the whole state
16511+ /// machine: the named file becomes the timeline (a `.edith` restoring a
16512+ /// whole one), everything else joins the library, including the very same
16513+ /// film dropped again once the open has landed.
16514+ #[test]
16515+ fn the_file_argv_named_lands_as_the_timeline_and_everything_behind_it_as_imports() {
16516+ let film = PathBuf::from("/films/Dune.mkv");
16517+ let extra = PathBuf::from("/films/Titles.mov");
16518+ let project = PathBuf::from("/films/Dune.edith");
16519+ assert_eq!(arrival(Some(&film), &film), Landing::Open);
16520+ assert_eq!(arrival(Some(&project), &project), Landing::Project);
16521+ assert_eq!(arrival(Some(&film), &extra), Landing::Import);
16522+ // Cleared as it lands: a drop of the film already on the timeline is an
16523+ // import, which is what a drop has always been.
16524+ assert_eq!(arrival(None, &film), Landing::Import);
16525+ // A window opened empty has no named file at all, and everything that
16526+ // arrives at it is an import.
16527+ assert_eq!(arrival(None, &project), Landing::Import);
16528+ }
16529+
16530+ /// What the window says while the file argv named is being read: the file's
16531+ /// name, the read that is running, and a clock proving the window is
16532+ /// answering -- in the *opening* wording, because the one person who typed
16533+ /// that name is not importing anything.
16534+ #[test]
16535+ fn the_named_file_is_read_under_an_opening_line_not_an_importing_one() {
16536+ let opening = import_line("Dune.mkv", ImportStage::Header, 0.4, 0.4, 1, true);
16537+ assert!(
16538+ opening.starts_with("OPENING Dune.mkv · reading the header"),
16539+ "{opening}"
16540+ );
16541+ assert!(opening.ends_with("· 1 more waiting"), "{opening}");
16542+ // Twelve seconds into a cold 25 GB header walk, which is the whole
16543+ // reason the window is up: it says the read is still moving through the
16544+ // same stage and that this is not a freeze.
16545+ let stalled = import_line("Dune.mkv", ImportStage::Header, 12., 12., 0, true);
16546+ assert!(stalled.starts_with("OPENING Dune.mkv · still"), "{stalled}");
16547+ assert!(stalled.contains("not frozen"), "{stalled}");
16548+ assert!(stalled.contains("0:12 elapsed"), "{stalled}");
16549+ // The files behind it are imports and still say so.
16550+ let import = import_line("Titles.mov", ImportStage::Header, 0.4, 0.4, 0, false);
16551+ assert!(import.starts_with("IMPORTING Titles.mov"), "{import}");
16552+ }
16553+
1629716554 /// One gesture over the real gate, with the plumbing around it spelled out:
1629816555 /// a write reseeks (the worker owes a frame again), a landed frame clears
1629916556 /// that and flushes what is held, and the release flushes whatever the
@@ -17784,103 +18041,40 @@ mod tests {
1778418041 }
1778518042
1778618043 fn main() {
17787- let arg = std::env::args().nth(1).map(PathBuf::from);
17788- // A `.edith` restores a whole timeline, anything else *is* the timeline.
17789- // Either way the rest of argv is imported into its library. No argument at
17790- // all opens the window empty -- the library then arrives by drop or by the
17791- // Import button, and everything below is derived from it at that point
17792- // instead.
17793- let mut session = match &arg {
17794- Some(arg) => {
17795- let opened = if is_project(arg) {
17796- PlaybackSession::open_project(arg)
17797- } else {
17798- PlaybackSession::open(arg)
17799- };
17800- match opened {
17801- Ok(v) => Some(v),
17802- Err(e) => {
17803- // A failed load by drop leaves the running session alone;
17804- // here a file was named and could not be opened, so the
17805- // refusal is the whole run.
17806- eprintln!("cannot open {}: {e}", arg.display());
17807- std::process::exit(1);
17808- }
17809- }
17810- }
17811- None => None,
17812- };
1781318044 // A keymap file that cannot be read leaves the defaults in force, and takes
17814- // the notice slot ahead of an import refusal below: it is about every key
17815- // the window has, and the import refusal is on stderr either way.
17816- let (keymap, mut notice) = Keymap::load();
18045+ // the notice slot ahead of an open or import refusal: it is about every key
18046+ // the window has, and those refusals are on stderr either way.
18047+ let (keymap, notice) = Keymap::load();
1781718048 if let Some(text) = &notice {
1781818049 eprintln!("{text}");
1781918050 }
17820- // The first file makes the timeline -- naming a file to open is a decision
17821- // about what to watch -- and the rest are imports like any other: rows in
17822- // the library, dragged onto a lane when they are wanted there.
18051+ // Nothing named on the command line is read here. The first file makes the
18052+ // timeline -- a `.edith` restores a whole one, anything else *is* one --
18053+ // and the rest are imports like any other: rows in the library, dragged
18054+ // onto a lane when they are wanted there. All of them go through the queue
18055+ // a drop uses ([`Player::import`]), which is the door with a progress line
18056+ // on it, and their refusals arrive in the notice bar as a drop's do.
1782318057 //
17824- // Queued rather than read here: three 25 GB remuxes on the command line
17825- // used to be half a minute of *no window at all*, and a window that has
17826- // not opened cannot say why. They go through the same door a drop does
17827- // ([`Player::import`]), which is the door with a progress line on it, and
17828- // the refusals arrive in the notice bar as a drop's do.
17829- let extras: Vec<PathBuf> = session
17830- .is_some()
17831- .then(|| std::env::args().skip(2).map(PathBuf::from).collect())
17832- .unwrap_or_default();
17833- // The subtitle tracks inside the file that *is* the timeline, taken at the
17834- // launch the window opens from -- the same pickup the drop and the Import
17835- // button make (`open_media`).
17836- if let (Some(session), Some(arg)) = (&mut session, &arg)
17837- && let Some(text) = subtitle_notice(session, arg)
17838- {
17839- eprintln!("{text}");
17840- }
17841- // A file that plays silent is as much news at launch as it is on a drop, and
17842- // behind the keymap notice for the same reason an import refusal is.
17843- if let Some(reason) = session
17844- .as_ref()
17845- .and_then(PlaybackSession::audio_disabled_reason)
17846- {
17847- let text = format!("NO AUDIO: {reason}");
17848- eprintln!("{text}");
17849- notice.get_or_insert(text);
17850- }
17851- let meta = session.as_ref().map(|session| *session.meta());
17852- // Beside the media even for a project: an export has never landed anywhere
17853- // but next to the picture it came from.
17854- let out = session.as_ref().map_or_else(PathBuf::new, |session| {
17855- export_path(&session.sources()[0].path)
17856- });
17857- let project = match &arg {
17858- Some(arg) if is_project(arg) => arg.clone(),
17859- Some(arg) => project_path(arg),
17860- // Chosen with the file, once there is one to choose it from.
17861- None => PathBuf::new(),
17862- };
18058+ // Queued rather than opened because a 25 GB film cold is twelve seconds of
18059+ // header walk, and it used to be twelve seconds of *no window at all* -- a
18060+ // window that has not opened cannot say what it is waiting for. Now the
18061+ // window is up in the time it takes to make one, naming the file and the
18062+ // read that is running, and the timeline appears when that read lands
18063+ // ([`Player::take_import`]).
18064+ //
18065+ // No argument at all opens the window empty, exactly as before: the library
18066+ // then arrives by drop or by the Import button.
18067+ let (arg, queue) = launch_queue(std::env::args().skip(1).map(PathBuf::from));
1786318068 let name: SharedString = arg
1786418069 .as_deref()
1786518070 .map_or_else(|| NO_FILE.into(), |arg| file_name(arg).into());
17866- if let (Some(arg), Some(meta)) = (&arg, &meta) {
17867- println!(
17868- "{}: {}x{} @ {:.2} fps, {} samples",
17869- arg.display(),
17870- meta.width,
17871- meta.height,
17872- meta.frame_rate,
17873- meta.frame_count
17874- );
17875- }
1787618071
1787718072 Application::new().run(move |cx: &mut App| {
17878- // The picture's own size, or 720p when there is no picture yet: the
17879- // empty window is a landing pad, not a sliver.
17880- let (w, h) = meta.map_or((1280., 720.), |meta| {
17881- (meta.width as f32, meta.height as f32)
17882- });
17883- let bounds = Bounds::centered(None, size(px(w), px(h)), cx);
18073+ // 720p: the picture's own size is not known yet -- knowing it is the
18074+ // twelve seconds this window exists to be up during -- and a window
18075+ // that resized itself under a hand already dragging it would be worse
18076+ // than one that opened at the size the empty window has always used.
18077+ let bounds = Bounds::centered(None, size(px(1280.), px(720.)), cx);
1788418078 cx.open_window(
1788518079 WindowOptions {
1788618080 window_bounds: Some(WindowBounds::Windowed(bounds)),
@@ -17897,14 +18091,14 @@ fn main() {
1789718091 ..Default::default()
1789818092 },
1789918093 |window, cx| {
17900- let extras = extras.clone();
18094+ let queue = queue.clone();
1790118095 let player = cx.new(|cx| Player {
17902- // A file named on the command line owes its first frame the
17903- // same repaint a seek's still owes: nothing plays by
17904- // itself, so this is what carries the poster frame to the
17905- // screen. An empty window has none to wait for.
17906- seek_since: session.is_some().then(Instant::now),
17907- session,
18096+ // Nothing to wait for yet: the file named on the command
18097+ // line is still queued, and the repaint that carries its
18098+ // poster frame to the screen is asked for when it lands
18099+ // (`open_media` -> `reset_after_reseek`).
18100+ seek_since: None,
18101+ session: None,
1790818102 // Full and unmuted, which is what the session it was just
1790918103 // handed is already set to: nothing to push at startup.
1791018104 volume: Volume::default(),
@@ -17912,7 +18106,10 @@ fn main() {
1791218106 volume_dragging: false,
1791318107 // Only ever used with a timeline; 30 keeps the empty
1791418108 // timecode reading in frames rather than in NaN.
17915- fps: meta.map_or(30., |meta| meta.frame_rate),
18109+ fps: 30.,
18110+ // The file being opened, from the first frame the window
18111+ // draws: the title bar and the header name it while its
18112+ // header is still being read.
1791618113 name: name.clone(),
1791718114 image: None,
1791818115 sub_image: None,
@@ -17948,8 +18145,11 @@ fn main() {
1794818145 cancelling: false,
1794918146 export_started: None,
1795018147 export_marks: Vec::new(),
17951- export_path: out.clone(),
17952- project_path: project.clone(),
18148+ // Both derived from the file when it lands, by the same
18149+ // `open_media`/`load_project` a drop goes through: an
18150+ // export beside the picture, a save beside it too.
18151+ export_path: PathBuf::new(),
18152+ project_path: PathBuf::new(),
1795318153 keymap: keymap.clone(),
1795418154 keys_open: false,
1795518155 keys_search: String::new(),
@@ -18007,10 +18207,11 @@ fn main() {
1800718207 rebinding: None,
1800818208 notice: notice.clone().map(SharedString::from),
1800918209 exported: None,
18010- // The rest of argv, waiting for the first repaint to start
18011- // them: the window is up before a byte of them is read.
18210+ // The whole of argv, waiting for the first repaint to start
18211+ // it: the window is up before a byte of it is read.
1801218212 importing: None,
18013- imports: extras.into(),
18213+ imports: queue,
18214+ opening: arg.clone(),
1801418215 // Nothing pushed yet, and never a real title: the first
1801518216 // render is what names the window.
1801618217 titled: String::new(),