Skip to content

Commit fd7238b

Browse files
committed
Merge large job pool refactor by kernel #1210
kernelkind (38): feat(blur): add BlurCache feat(cargo): add crossbeam feat(gif): add AnimatedImgTexCache feat(gif): new Animation feat(gif): new ProcessedGifFrame feat(hyper): install crypto provider feat(images): new TextureState feat(img-parsing): new parse_img_response feat(job-cache): new JobCache feat(jobs): add `schedule_receivable` feat(jobs): mpsc -> mpmc feat(jobs): structs for new JobCache feat(jobs-media): basic media jobs structs feat(media-job): pre & post actions feat(media-jobs): add media JobCache to app feat(media-loading): Images helpers feat(media-loading): add TexturesCache to Images feat(media-loading): new Images::latest_texture feat(media-loading): new TexturesCache feat(media-loading): wire new media loading cache feat(media-rendering): add helpers for various media rendering configs feat(network): add hyper feat(network): hyper networking feat(static-imgs): add StaticImgTexCache refactor(gif): nevernest process_gif_frame refactor(jobs): move related jobs things to own module refactor(search): remove unnecessary params refactor: appease clippy refactor: remove unnecessary old JobsCache code tmp(refactor): Animation -> AnimationOld tmp(refactor): Images::latest_texture -> latest_texture_old tmp(refactor): MediaRenderState -> MediaRenderStateOld tmp(refactor): ObfuscatedTexture -> ObfuscatedTextureOld tmp(refactor): ProcessedGifFrame -> ProcessedGifFrameOld tmp(refactor): TextureState -> TextureStateOld tmp(refactor): TexturesCache -> TexturesCacheOld tmp(refactor): parse_img_response -> parse_img_response_old tmp(refactor): rename current jobs stuff to Old
2 parents 9e4c920 + 4413e18 commit fd7238b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2065
-1516
lines changed

Cargo.lock

Lines changed: 129 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ egui_tabs = { git = "https://github.com/damus-io/egui-tabs", rev = "6eb91740577b
3333
#egui_virtual_list = "0.6.0"
3434
egui_virtual_list = { git = "https://github.com/jb55/hello_egui", rev = "a66b6794f5e707a2f4109633770e02b02fb722e1" }
3535
ehttp = "0.5.0"
36+
hyper = { version = "1.7.0", features = ["full"] }
37+
hyper-util = {version = "0.1" , features = ["tokio"]}
38+
hyper-rustls = "0.27.7"
39+
http-body-util = "0.1.3"
40+
rustls = "0.23.28"
3641
enostr = { path = "crates/enostr" }
3742
ewebsock = { version = "0.2.0", features = ["tls"] }
3843
fluent = "0.17.0"

crates/notedeck/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ chrono = { workspace = true }
5353
indexmap = {workspace = true}
5454
rand = {workspace = true}
5555
crossbeam-channel = "0.5"
56+
crossbeam = "0.8.4"
57+
hyper = { workspace = true }
58+
hyper-util = { workspace = true }
59+
http-body-util = { workspace = true }
60+
hyper-rustls = { workspace = true }
61+
rustls = { workspace = true }
5662

5763
[dev-dependencies]
5864
tempfile = { workspace = true }

crates/notedeck/src/app.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use crate::i18n::Localization;
33
use crate::persist::{AppSizeHandler, SettingsHandler};
44
use crate::wallet::GlobalWallet;
55
use crate::zaps::Zaps;
6-
use crate::Error;
7-
use crate::JobPool;
86
use crate::NotedeckOptions;
97
use crate::{
108
frame_history::FrameHistory, AccountStorage, Accounts, AppContext, Args, DataPath,
119
DataPathType, Directory, Images, NoteAction, NoteCache, RelayDebugView, UnknownIds,
1210
};
11+
use crate::{Error, JobCache};
12+
use crate::{JobPool, MediaJobs};
1313
use egui::Margin;
1414
use egui::ThemePreference;
1515
use egui_winit::clipboard::Clipboard;
@@ -77,6 +77,7 @@ pub struct Notedeck {
7777
zaps: Zaps,
7878
frame_history: FrameHistory,
7979
job_pool: JobPool,
80+
media_jobs: MediaJobs,
8081
i18n: Localization,
8182

8283
#[cfg(target_os = "android")]
@@ -122,6 +123,13 @@ impl eframe::App for Notedeck {
122123
self.frame_history
123124
.on_new_frame(ctx.input(|i| i.time), frame.info().cpu_usage);
124125

126+
self.media_jobs.run_received(&mut self.job_pool, |id| {
127+
crate::run_media_job_pre_action(id, &mut self.img_cache.textures);
128+
});
129+
self.media_jobs.deliver_all_completed(|completed| {
130+
crate::deliver_completed_media_job(completed, &mut self.img_cache.textures)
131+
});
132+
125133
// handle account updates
126134
self.accounts.update(&mut self.ndb, &mut self.pool, ctx);
127135

@@ -177,6 +185,8 @@ impl Notedeck {
177185
#[cfg(feature = "puffin")]
178186
setup_puffin();
179187

188+
install_crypto();
189+
180190
// Skip the first argument, which is the program name.
181191
let (parsed_args, unrecognized_args) = Args::parse(&args[1..]);
182192

@@ -288,6 +298,9 @@ impl Notedeck {
288298
}
289299
}
290300

301+
let (send_new_jobs, receive_new_jobs) = std::sync::mpsc::channel();
302+
let media_job_cache = JobCache::new(receive_new_jobs, send_new_jobs);
303+
291304
Self {
292305
ndb,
293306
img_cache,
@@ -306,6 +319,7 @@ impl Notedeck {
306319
clipboard: Clipboard::new(None),
307320
zaps,
308321
job_pool,
322+
media_jobs: media_job_cache,
309323
i18n,
310324
#[cfg(target_os = "android")]
311325
android_app: None,
@@ -371,6 +385,7 @@ impl Notedeck {
371385
zaps: &mut self.zaps,
372386
frame_history: &mut self.frame_history,
373387
job_pool: &mut self.job_pool,
388+
media_jobs: &mut self.media_jobs,
374389
i18n: &mut self.i18n,
375390
#[cfg(target_os = "android")]
376391
android: self.android_app.as_ref().unwrap().clone(),
@@ -401,3 +416,8 @@ impl Notedeck {
401416
&self.unrecognized_args
402417
}
403418
}
419+
420+
pub fn install_crypto() {
421+
let provider = rustls::crypto::aws_lc_rs::default_provider();
422+
let _ = provider.install_default();
423+
}

crates/notedeck/src/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
account::accounts::Accounts, frame_history::FrameHistory, i18n::Localization,
3-
wallet::GlobalWallet, zaps::Zaps, Args, DataPath, Images, JobPool, NoteCache, SettingsHandler,
4-
UnknownIds,
3+
wallet::GlobalWallet, zaps::Zaps, Args, DataPath, Images, JobPool, MediaJobs, NoteCache,
4+
SettingsHandler, UnknownIds,
55
};
66
use egui_winit::clipboard::Clipboard;
77

@@ -28,6 +28,7 @@ pub struct AppContext<'a> {
2828
pub zaps: &'a mut Zaps,
2929
pub frame_history: &'a mut FrameHistory,
3030
pub job_pool: &'a mut JobPool,
31+
pub media_jobs: &'a mut MediaJobs,
3132
pub i18n: &'a mut Localization,
3233

3334
#[cfg(target_os = "android")]

0 commit comments

Comments
 (0)