Merge pull request #8101 from dotCooCoo/feat/plugin-budget-preference

Plug-ins: Preferences set the instruction budget for object-filter runs (Normal or Large)
This commit is contained in:
BFlat
2026-11-18 15:10:33 +07:00
committed by GitHub
41 changed files with 239 additions and 7 deletions
+15 -3
View File
@@ -161,6 +161,8 @@ pub struct FilterRun {
parent: Option<NodeId>,
/// The document it was made from, and that document's revision then.
document: (u64, u64),
/// The plug-in's limits with the Plug-in Instruction Budget in force when it was made.
limits: vectorcraft_plugins::Limits,
}
/// A filter's output handed in by a [`FilterRun`] made away from `plugin.run`, with what the run
@@ -245,7 +247,11 @@ impl FilterRun {
let capacity = (plugin.limits().max_memory_bytes / 2).min(i32::MAX as usize).saturating_sub(params.len());
let (input, read_only) = objects::encode_input_with(&st.doc, &inputs, &kinds, capacity).map_err(err)?;
let document = (st.uid, st.revision);
Ok(FilterRun { plugin, command, input, params, inputs, read_only, parent, document })
let limits = match s.prefs.plugin_instruction_budget {
crate::PluginBudget::Normal => plugin.limits().clone(),
crate::PluginBudget::Large => plugin.large_limits(),
};
Ok(FilterRun { plugin, command, input, params, inputs, read_only, parent, document, limits })
}
/// The plug-in, for its name and budget.
@@ -274,7 +280,13 @@ impl FilterRun {
/// can run on any thread; inside a [`vectorcraft_doc::cancel::scope`] Cancel stops it between
/// two slices of its budget.
pub fn run(&self) -> Result<Vec<u8>> {
self.plugin.run(&self.input, &self.params).map_err(err)
self.plugin.run_limited(&self.input, &self.params, &self.limits).map_err(err)
}
/// The limits it runs under: the plug-in's, with the Plug-in Instruction Budget in force when
/// it was made.
pub fn limits(&self) -> &vectorcraft_plugins::Limits {
&self.limits
}
/// Does the plug-in call commands (its manifest's `commandAllowlist`)? Then it runs only in the
@@ -289,7 +301,7 @@ impl FilterRun {
let may = self.plugin.manifest().permissions();
let calls = super::plugin_call::Calls::of(s, may.contains(&Permission::DocRead), may.contains(&Permission::DocWrite));
let mut bridge = |id: &str, args: &Value| super::plugin_call::call(s, &calls, id, args);
self.plugin.run_calling(&self.input, &self.params, self.plugin.limits(), &mut bridge).0.map_err(err)
self.plugin.run_calling(&self.input, &self.params, &self.limits, &mut bridge).0.map_err(err)
}
/// Runs a plug-in that calls commands and applies its output: the calls and the output are one
+8
View File
@@ -324,6 +324,14 @@ pub const PREF_SPECS: &[PrefSpec] = &[
p!("hyphenationExceptions", "Hyphenation", "", "Exceptions (comma separated)", text),
// Plug-ins & Scratch Disks
p!("pluginsFolder", "Plug-ins & Scratch Disks", "Plug-ins", "Additional Plug-ins Folder", text),
// The instructions each object filter run gets: Large gives at least 250 M besides those for each byte of input.
p!(
"pluginInstructionBudget",
"Plug-ins & Scratch Disks",
"Plug-ins",
"Plug-in Instruction Budget",
choice(&[("normal", "Normal"), ("large", "Large")])
),
p!("scratchPrimary", "Plug-ins & Scratch Disks", "Scratch Disks", "Primary", text),
p!("scratchSecondary", "Plug-ins & Scratch Disks", "Scratch Disks", "Secondary", text),
// User Interface
+1 -1
View File
@@ -415,7 +415,7 @@ use history::history_budget_for;
pub use history::{History, HistoryEntry, NamedStep, default_history_budget};
pub(crate) use interaction::PreviewCopies;
pub use interaction::{Interaction, LastTransform, UndoGroup, UndoScope};
pub use prefs::{DrawMode, Prefs};
pub use prefs::{DrawMode, PluginBudget, Prefs};
pub use sanity::TOO_DEEP;
pub(crate) use sanity::{deselect_hidden, is_guide_path};
#[cfg(test)]
+26
View File
@@ -10,6 +10,26 @@ pub enum DrawMode {
Inside,
}
/// Plug-ins & Scratch Disks › Plug-in Instruction Budget: the instructions an object filter's run
/// may use ([`vectorcraft_plugins::Plugin::large_limits`]).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Serialize)]
#[serde(rename_all = "lowercase")]
pub enum PluginBudget {
/// The plug-in's own limits.
#[default]
Normal,
/// At least [`vectorcraft_plugins::LARGE_FUEL`] instructions besides those for each byte of
/// input; the time budget is unchanged.
Large,
}
/// A saved Plug-in Instruction Budget: any value but `large`, of any type, reads as Normal, and the
/// other preferences are read as they are.
fn plugin_budget<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result<PluginBudget, D::Error> {
let saved = <Value as serde::Deserialize>::deserialize(d)?;
Ok(if saved.as_str() == Some("large") { PluginBudget::Large } else { PluginBudget::Normal })
}
/// A saved Default Language as its tag: older preferences hold the language's name, and one the list
/// no longer has reads as the default.
fn language_tag<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result<String, D::Error> {
@@ -179,6 +199,11 @@ pub struct Prefs {
pub fonts_folder: String,
// Plug-ins & Scratch Disks
pub plugins_folder: String,
/// Plug-in Instruction Budget: the instructions each object filter run gets, from
/// `plugin.run`, a plug-in command and the app alike. Live effects, exporters and importers
/// keep their own budgets.
#[serde(deserialize_with = "plugin_budget")]
pub plugin_instruction_budget: PluginBudget,
pub scratch_primary: String,
pub scratch_secondary: String,
// User Interface
@@ -496,6 +521,7 @@ impl Default for Prefs {
hyphenation_exceptions: String::new(),
fonts_folder: String::new(),
plugins_folder: String::new(),
plugin_instruction_budget: PluginBudget::Normal,
scratch_primary: s("Startup"),
scratch_secondary: s("None"),
ui_brightness: s("mediumDark"),
+53
View File
@@ -4446,6 +4446,59 @@ fn a_cancelled_filter_run_changes_nothing() {
assert_eq!(s.doc().unwrap().doc, before);
}
/// Preferences › Plug-ins & Scratch Disks › Plug-in Instruction Budget: with Normal a light filter
/// runs out of instructions and changes nothing; with Large the same installed filter finishes, as
/// one undo step, without being installed again. The time budget, Cancel and a heavy filter's
/// larger budget stay as they are, and setting Normal again applies to the next run.
#[test]
fn the_plugin_instruction_budget_preference_sets_a_filter_run_s_instructions() {
use cmd::plugin::FilterRun;
let mut s = session();
let id = "test.engine.largebudget";
let output = json!({"objects": [{"path": triangle(), "name": "Plug-in"}]}).to_string();
// More steps than a light budget pays for, fewer than 5 times it.
install_wat(&mut s, &tpl::spinning(&tpl::manifest(id, "filter", "{}"), 20_000_000, &output));
let p = json!({"id": id, "ids": []});
let (before, undo) = (s.doc().unwrap().doc.clone(), s.doc().unwrap().history.undo.len());
let e = s.execute("plugin.run", &p).unwrap_err().to_string();
assert!(e.contains("instruction budget"), "{e}");
assert_eq!((&s.doc().unwrap().doc, s.doc().unwrap().history.undo.len()), (&before, undo));
run(&mut s, "prefs.set", json!({"key": "pluginInstructionBudget", "value": "large"}));
let light = vectorcraft_plugins::Limits::default();
let large = FilterRun::prepare(&s, &p).unwrap().limits().clone();
assert_eq!(large, vectorcraft_plugins::Limits { fuel_base: vectorcraft_plugins::LARGE_FUEL, ..light.clone() });
assert_eq!((large.fuel_per_byte, large.wall_time_ms), (light.fuel_per_byte, light.wall_time_ms));
// Cancel still stops it, and it changes nothing.
let token = vectorcraft_doc::cancel::CancelToken::new();
token.cancel();
let r = vectorcraft_doc::cancel::scope(&token, None, || s.execute("plugin.run", &p));
assert!(matches!(r, Err(EngineError::Cancelled)), "{r:?}");
assert_eq!((&s.doc().unwrap().doc, s.doc().unwrap().history.undo.len()), (&before, undo));
let made = run(&mut s, "plugin.run", p.clone())["ids"].clone();
assert_eq!(made.as_array().map(Vec::len), Some(1));
assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1);
// A heavy filter keeps its larger budget with either choice.
let heavy_id = "test.engine.largebudget.heavy";
run(&mut s, "plugin.install", json!({"dataBase64": vectorcraft_format::base64_encode(&heavy(heavy_id, 1)), "allowHeavy": true}));
let hp = json!({"id": heavy_id, "ids": []});
for budget in ["large", "normal"] {
run(&mut s, "prefs.set", json!({"key": "pluginInstructionBudget", "value": budget}));
let limits = FilterRun::prepare(&s, &hp).unwrap().limits().clone();
let heavy_limits = (vectorcraft_plugins::HEAVY_FUEL, vectorcraft_plugins::HEAVY_WALL_TIME_MS);
assert_eq!((limits.fuel_base, limits.wall_time_ms), heavy_limits, "{budget}");
}
// Normal again: the next run runs out of instructions.
let undo = s.doc().unwrap().history.undo.len();
let e = s.execute("plugin.run", &p).unwrap_err().to_string();
assert!(e.contains("instruction budget"), "{e}");
assert_eq!(s.doc().unwrap().history.undo.len(), undo);
run(&mut s, "plugin.remove", json!({"id": id}));
run(&mut s, "plugin.remove", json!({"id": heavy_id}));
}
/// The manifest of a filter `id` named "Cmd Test" of `kind` with `commands` (a JSON list).
fn with_commands(id: &str, kind: &str, commands: &str) -> String {
format!(r#"{{"id":"{id}","name":"Cmd Test","version":"1","kind":"{kind}","commands":{commands}}}"#)
+32
View File
@@ -464,6 +464,38 @@ fn gpu_preference_defaults_to_automatic_and_validates() {
assert_eq!(s.prefs.gpu_preference, "automatic");
}
/// Plug-ins & Scratch Disks › Plug-in Instruction Budget: Normal by default, Large by value or
/// label, kept through a save and load, and reset with its category. Setting another value is an
/// error that changes nothing; a saved value that is missing, unknown or of another type reads as
/// Normal and leaves the other saved preferences as they are.
#[test]
fn plugin_instruction_budget_defaults_to_normal_and_validates() {
let mut s = Session::new();
assert_eq!(s.prefs.plugin_instruction_budget, PluginBudget::Normal);
assert_eq!(s.execute("prefs.get", &json!({"key": "pluginInstructionBudget"})).unwrap(), json!("normal"));
set_pref(&mut s, "pluginInstructionBudget", json!("Large"));
assert_eq!(s.prefs.plugin_instruction_budget, PluginBudget::Large);
assert_eq!(s.execute("prefs.get", &json!({"key": "pluginInstructionBudget"})).unwrap(), json!("large"));
for bad in [json!("unlimited"), json!(""), json!(5), json!(null), json!(true), json!(["large"])] {
assert!(s.execute("prefs.set", &json!({"key": "pluginInstructionBudget", "value": bad})).is_err(), "{bad}");
assert_eq!(s.prefs.plugin_instruction_budget, PluginBudget::Large, "{bad}");
}
let back: Prefs = serde_json::from_value(s.prefs.to_json()).unwrap();
assert_eq!(back.plugin_instruction_budget, PluginBudget::Large);
let other_values = [json!("unlimited"), json!(5), json!(null), json!(["large"]), json!({"large": true}), json!("LARGE")];
let saved_files = other_values.map(|v| json!({"keyboardIncrement": 4, "pluginInstructionBudget": v}));
for saved in std::iter::once(json!({"keyboardIncrement": 4})).chain(saved_files) {
let read: Prefs = serde_json::from_value(saved.clone()).unwrap();
assert_eq!((read.plugin_instruction_budget, read.keyboard_increment), (PluginBudget::Normal, 4.0), "{saved}");
}
let l = s.execute("prefs.list", &json!({})).unwrap();
let row = l.as_array().unwrap().iter().find(|e| e["key"] == "pluginInstructionBudget").unwrap().clone();
assert_eq!((row["category"].as_str(), row["section"].as_str()), (Some("Plug-ins & Scratch Disks"), Some("Plug-ins")));
assert_eq!((&row["options"], &row["value"]), (&json!(["normal", "large"]), &json!("large")));
s.execute("prefs.reset", &json!({"category": "Plug-ins & Scratch Disks"})).unwrap();
assert_eq!(s.prefs.plugin_instruction_budget, PluginBudget::Normal);
}
/// Performance › Low-Latency Drawing (#6013): off by default and for preference files written
/// before it, a boolean only, kept through a save/load round trip, listed under Performance and
/// reset with it.
+1 -1
View File
@@ -53,7 +53,7 @@ pub mod wat;
pub use dialog::ParamUi;
pub use host::{LogLevel, LogLine, Report};
pub use manifest::{Budget, Command, InputKind, Kind, Manifest, Param, ParamSpec};
pub use runtime::{ABI_VERSION, HEAVY_FUEL, HEAVY_WALL_TIME_MS, Limits, Plugin, heavy_terms};
pub use runtime::{ABI_VERSION, HEAVY_FUEL, HEAVY_WALL_TIME_MS, LARGE_FUEL, Limits, Plugin, heavy_terms};
#[doc(hidden)]
pub use runtime::{BYTES_COPIED_PER_FUEL, FUEL_SLICE};
+11
View File
@@ -35,6 +35,11 @@ pub const HEAVY_FUEL: u64 = 1_000_000_000;
/// Wall-clock budget of a heavy filter's run, in milliseconds.
pub const HEAVY_WALL_TIME_MS: u64 = 300_000;
/// Instructions a filter's run may use besides [`Limits::fuel_per_byte`] for each byte of input
/// when Preferences › Plug-ins & Scratch Disks › Plug-in Instruction Budget is Large
/// ([`Plugin::large_limits`]): 5 times the default.
pub const LARGE_FUEL: u64 = 250_000_000;
/// The limit a run reports when its input and parameters together are past half its memory.
pub(crate) const SELECTION_TOO_LARGE: &str = "memory budget (the selection is too large to hand over)";
@@ -215,6 +220,12 @@ impl Plugin {
pub fn limits(&self) -> &Limits {
&self.limits
}
/// Its limits with the Large instruction budget: at least [`LARGE_FUEL`] instructions besides
/// those for each byte of input, and every other limit, the time budget included, as it is. A
/// heavy filter keeps its larger budget.
pub fn large_limits(&self) -> Limits {
Limits { fuel_base: self.limits.fuel_base.max(LARGE_FUEL), ..self.limits.clone() }
}
/// Module size in bytes.
pub fn size(&self) -> usize {
self.size
+18 -1
View File
@@ -7,7 +7,7 @@ use std::time::{Duration, Instant};
use serde_json::{Value, json};
use vectorcraft_plugins::storage::{Meter, Storage, StorageError};
use vectorcraft_plugins::{Error, HEAVY_FUEL, HEAVY_WALL_TIME_MS, Kind, Limits, Plugin, Report, heavy_terms, registry, wat as tpl};
use vectorcraft_plugins::{Error, HEAVY_FUEL, HEAVY_WALL_TIME_MS, Kind, LARGE_FUEL, Limits, Plugin, Report, heavy_terms, registry, wat as tpl};
/// The example Desaturate plug-in, built from `crates/plugins/example`.
const DESATURATE: &[u8] = include_bytes!("fixtures/desaturate.wasm");
@@ -259,6 +259,23 @@ fn a_heavy_filter_finishes_what_a_light_one_cannot() {
assert_eq!(p.run(INPUT.as_bytes(), b"{}").unwrap(), INPUT.as_bytes());
}
/// The Large instruction budget gives a light filter 5 times the instructions besides those for
/// each byte of input, so it finishes 20 million steps of a loop that its own budget can't, in the
/// same time budget. A heavy filter keeps its larger budget, and every other limit stays.
#[test]
fn the_large_budget_finishes_what_a_light_one_cannot_and_keeps_a_heavy_one() {
let light = Plugin::load(&build(&tpl::spinning(MANIFEST, 20_000_000, INPUT)), Limits::default()).unwrap();
assert_eq!(light.run(INPUT.as_bytes(), b"{}"), Err(Error::Limit("instruction budget".into())));
let large = light.large_limits();
assert_eq!(large, Limits { fuel_base: LARGE_FUEL, ..Limits::default() });
assert_eq!(LARGE_FUEL, 5 * Limits::default().fuel_base);
assert_eq!(light.run_limited(INPUT.as_bytes(), b"{}", &large).unwrap(), INPUT.as_bytes());
let heavy = r#"{"id":"test.heavy","name":"Heavy","version":"1","kind":"filter","budget":"heavy"}"#;
let heavy = Plugin::load(&build(&tpl::spinning(heavy, 1, INPUT)), Limits::default()).unwrap();
assert_eq!(heavy.large_limits(), *heavy.limits());
assert_eq!((heavy.large_limits().fuel_base, heavy.large_limits().wall_time_ms), (HEAVY_FUEL, HEAVY_WALL_TIME_MS));
}
#[test]
fn an_exporter_returns_its_file_with_an_export_s_budget() {
use vectorcraft_plugins::export::{self, Target};
+1
View File
@@ -127,6 +127,7 @@
Add to Swatches Добавяне към образци
Add Used Colors Добавяне на използваните цветове
Additional Plug-ins Folder Допълнителна папка за плъгини
Plug-in Instruction Budget Бюджет на инструкции за плъгини
Additional Fonts Folder Допълнителна папка за шрифтове
Adjust Adjoining Width Points Регулиране на прилежащите точки за ширина
Incoming Входяща
Can't render this file because it is too large.
+1
View File
@@ -3944,6 +3944,7 @@ theme Appearance Izgled
90° & 45° Angles Uglovi od 90° i 45°
90° Angles Uglovi od 90°
Additional Plug-ins Folder Dodatni folder dodataka
Plug-in Instruction Budget Budžet instrukcija za dodatke
Additional Fonts Folder Dodatni folder fontova
Alignment Guides Vodilice za poravnanje
Anchor Points, Handle, and Bounding Box Display Prikaz sidrenih tačaka, ručki i graničnog okvira
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -223,6 +223,7 @@
Add Used Colors Afegeix els colors utilitzats
Additional Fonts Folder Carpeta addicional de tipus de lletra
Additional Plug-ins Folder Carpeta addicional de complements
Plug-in Instruction Budget Pressupost d’instruccions dels complements
Adjust Adjoining Width Points Ajusta els punts d’amplada contigus
Incoming Entrant
Outgoing Sortint
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4048,6 +4048,7 @@ theme Appearance Motiv
90° & 45° Angles Úhly 90° a 45°
90° Angles Úhly 90°
Additional Plug-ins Folder Další složka zásuvných modulů
Plug-in Instruction Budget Rozpočet instrukcí zásuvných modulů
Additional Fonts Folder Další složka písem
Alignment Guides Vodítka zarovnání
Anchor Points, Handle, and Bounding Box Display Zobrazení kotevních bodů, úchytů a ohraničovacího rámečku
Can't render this file because it is too large.
+1
View File
@@ -6497,6 +6497,7 @@ theme Appearance Udseende
90° & 45° Angles 90° & 45°-vinkler
90° Angles 90°-vinkler
Additional Plug-ins Folder Yderligere mappe med plug-ins
Plug-in Instruction Budget Instruktionsbudget for plug-ins
Additional Fonts Folder Yderligere mappe med skrifttyper
Alignment Guides Justeringshjælpelinjer
Anchor Points, Handle, and Bounding Box Display Visning af ankerpunkter, håndtag og afgrænsningsboks
Can't render this file because it is too large.
+1
View File
@@ -116,6 +116,7 @@
Add to Swatches Zu Farbfeldern hinzufügen
Add Used Colors Verwendete Farben hinzufügen
Additional Plug-ins Folder Zusätzlicher Plug-in-Ordner
Plug-in Instruction Budget Anweisungsbudget für Plug-ins
Additional Fonts Folder Zusätzlicher Schriftenordner
Adjust Adjoining Width Points Angrenzende Breitenpunkte anpassen
Incoming Eingehend
Can't render this file because it is too large.
+1
View File
@@ -121,6 +121,7 @@
Add to Swatches Προσθήκη στα δείγματα χρωμάτων
Add Used Colors Προσθήκη των χρησιμοποιημένων χρωμάτων
Additional Plug-ins Folder Πρόσθετος φάκελος επεκτάσεων
Plug-in Instruction Budget Προϋπολογισμός εντολών επεκτάσεων
Additional Fonts Folder Πρόσθετος φάκελος γραμματοσειρών
Adjust Adjoining Width Points Ρύθμιση γειτονικών σημείων πλάτους
Incoming Εισερχόμενο
Can't render this file because it is too large.
+1
View File
@@ -141,6 +141,7 @@
Add to Swatches Agregar a muestras
Add Used Colors Agregar colores usados
Additional Plug-ins Folder Carpeta de plugins adicionales
Plug-in Instruction Budget Presupuesto de instrucciones de plugins
Additional Fonts Folder Carpeta de fuentes adicionales
Adjust Adjoining Width Points Ajustar puntos de anchura contiguos
Incoming Entrante
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -3984,6 +3984,7 @@ theme Appearance Ulkoasu
90° & 45° Angles 90° ja 45° kulmat
90° Angles 90° kulmat
Additional Plug-ins Folder Lisälaajennusten kansio
Plug-in Instruction Budget Laajennusten käskybudjetti
Additional Fonts Folder Lisäfonttien kansio
Alignment Guides Tasausapuviivat
Anchor Points, Handle, and Bounding Box Display Ankkuripisteiden, kahvojen ja rajausruudun näyttö
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -142,6 +142,7 @@
Add to Swatches Ajouter au nuancier
Add Used Colors Ajouter les couleurs utilisées
Additional Plug-ins Folder Dossier de modules externes supplémentaires
Plug-in Instruction Budget Budget d’instructions des modules externes
Additional Fonts Folder Dossier de polices supplémentaires
Adjust Adjoining Width Points Ajuster les points de largeur adjacents
Incoming Entrant
Can't render this file because it is too large.
+1
View File
@@ -164,6 +164,7 @@
Add to the Current Shortcuts વર્તમાન શૉર્ટકટમાં ઉમેરો
Additional Fonts Folder વધારાનું ફોન્ટ ફોલ્ડર
Additional Plug-ins Folder વધારાનું પ્લગ-ઇન ફોલ્ડર
Plug-in Instruction Budget પ્લગ-ઇન સૂચના બજેટ
Adjust Adjoining Width Points અડીને આવેલા પહોળાઈ બિંદુઓ ગોઠવો
Incoming આવતી બાજુ
Outgoing જતી બાજુ
Can't render this file because it contains an unexpected character in line 72 and column 5.
+1
View File
@@ -257,6 +257,7 @@
Add Used Colors उपयोग किए रंग जोड़ें
Additional Fonts Folder अतिरिक्त फ़ॉन्ट फ़ोल्डर
Additional Plug-ins Folder अतिरिक्त प्लग-इन फ़ोल्डर
Plug-in Instruction Budget प्लग-इन निर्देश बजट
Adjust Adjoining Width Points सटे हुए चौड़ाई पॉइंट समायोजित करें
Incoming आने वाली ओर
Outgoing जाने वाली ओर
Can't render this file because it is too large.
+1
View File
@@ -211,6 +211,7 @@
Add Used Colors Használt színek hozzáadása
Additional Fonts Folder További betűtípusok mappája
Additional Plug-ins Folder További bővítmények mappája
Plug-in Instruction Budget Bővítmények utasításkerete
Adjust Adjoining Width Points Szomszédos szélességi pontok igazítása
Incoming Bejövő
Outgoing Kimenő
Can't render this file because it is too large.
+1
View File
@@ -3715,6 +3715,7 @@ theme Appearance Tampilan
90° & 45° Angles Sudut 90° & 45°
90° Angles Sudut 90°
Additional Plug-ins Folder Folder plug-in tambahan
Plug-in Instruction Budget Anggaran instruksi plug-in
Additional Fonts Folder Folder font tambahan
Alignment Guides Panduan perataan
Anchor Points, Handle, and Bounding Box Display Tampilan titik jangkar, pegangan, dan kotak pembatas
Can't render this file because it contains an unexpected character in line 2538 and column 5.
+1
View File
@@ -141,6 +141,7 @@
Add to Swatches Aggiungi ai campioni
Add Used Colors Aggiungi colori usati
Additional Plug-ins Folder Cartella plug-in aggiuntivi
Plug-in Instruction Budget Budget di istruzioni dei plug-in
Additional Fonts Folder Cartella font aggiuntivi
Adjust Adjoining Width Points Regola punti di larghezza adiacenti
Incoming In entrata
Can't render this file because it is too large.
+1
View File
@@ -1093,6 +1093,7 @@ digits Malayalam マラヤーラム数字
Add to Selection 選択範囲に追加
Add to Swatches スウォッチに追加
Additional Plug-ins Folder 追加プラグインフォルダー
Plug-in Instruction Budget プラグインの命令予算
Additional Fonts Folder 追加フォントフォルダー
Adjust Adjoining Width Points 隣接する幅ポイントを調整
Incoming 入り側
Can't render this file because it is too large.
+1
View File
@@ -5810,6 +5810,7 @@ theme Appearance იერსახე
90° & 45° Angles 90° და 45° კუთხეები
90° Angles 90° კუთხეები
Additional Plug-ins Folder დამატებითი პლაგინები
Plug-in Instruction Budget პლაგინების ინსტრუქციების ბიუჯეტი
Additional Fonts Folder შრიფტების დამატებითი საქაღალდე
Alignment Guides გასწორების დამხმარე ხაზები
Anchor Points, Handle, and Bounding Box Display საყრდენი წერტილების, სახელურებისა და შემომსაზღვრელი ჩარჩოს ჩვენება
Can't render this file because it is too large.
+1
View File
@@ -1083,6 +1083,7 @@ digits Malayalam 말라얄람어
Add to Selection 선택 영역에 추가
Add to Swatches 견본에 추가
Additional Plug-ins Folder 추가 플러그인 폴더
Plug-in Instruction Budget 플러그인 명령어 예산
Additional Fonts Folder 추가 글꼴 폴더
Adjust Adjoining Width Points 인접한 너비 점 조정
Incoming 들어오는 쪽
Can't render this file because it is too large.
+1
View File
@@ -4370,6 +4370,7 @@ theme Appearance Vormgeving
90° & 45° Angles Hoeken van 90° & 45°
90° Angles Hoeken van 90°
Additional Plug-ins Folder Extra map met plug-ins
Plug-in Instruction Budget Instructiebudget voor plug-ins
Additional Fonts Folder Extra map met lettertypen
Alignment Guides Uitlijnhulplijnen
Anchor Points, Handle, and Bounding Box Display Weergave van ankerpunten, greep en begrenzingskader
Can't render this file because it is too large.
+1
View File
@@ -3927,6 +3927,7 @@ theme Appearance Wygląd
90° & 45° Angles Kąty 90° i 45°
90° Angles Kąty 90°
Additional Plug-ins Folder Dodatkowy folder wtyczek
Plug-in Instruction Budget Budżet instrukcji wtyczek
Additional Fonts Folder Dodatkowy folder czcionek
Alignment Guides Linie wyrównania
Anchor Points, Handle, and Bounding Box Display Wyświetlanie punktów kontrolnych, uchwytów i obwiedni
Can't render this file because it is too large.
+1
View File
@@ -147,6 +147,7 @@
Add to Selection Adicionar à Seleção
Add to Swatches Adicionar às Amostras
Additional Plug-ins Folder Pasta Adicional de Plug-ins
Plug-in Instruction Budget Orçamento de Instruções de Plug-ins
Additional Fonts Folder Pasta Adicional de Fontes
Adjust Adjoining Width Points Ajustar Pontos de Largura Adjacentes
Incoming Entrada
Can't render this file because it is too large.
+1
View File
@@ -139,6 +139,7 @@
Add to Swatches Добавить в образцы
Add Used Colors Добавить использованные цвета
Additional Plug-ins Folder Папка дополнительных модулей
Plug-in Instruction Budget Бюджет инструкций модулей
Additional Fonts Folder Папка дополнительных шрифтов
Adjust Adjoining Width Points Настроить смежные точки ширины
Incoming Входящая
Can't render this file because it is too large.
+1
View File
@@ -129,6 +129,7 @@
Add to Swatches Lägg till i färgrutor
Add Used Colors Lägg till använda färger
Additional Plug-ins Folder Mapp för ytterligare plugins
Plug-in Instruction Budget Instruktionsbudget för plugins
Additional Fonts Folder Mapp för ytterligare typsnitt
Adjust Adjoining Width Points Justera angränsande breddpunkter
Incoming Inkommande
Can't render this file because it is too large.
+1
View File
@@ -126,6 +126,7 @@
Add to Swatches Renk Örneklerine Ekle
Add Used Colors Kullanılan Renkleri Ekle
Additional Plug-ins Folder Ek Eklentiler Klasörü
Plug-in Instruction Budget Eklenti Talimat Bütçesi
Additional Fonts Folder Ek Yazı Tipleri Klasörü
Adjust Adjoining Width Points Bitişik Genişlik Noktalarını Ayarlayın
Incoming Gelen
Can't render this file because it is too large.
+1
View File
@@ -135,6 +135,7 @@
Add to Swatches Додати до зразків
Add Used Colors Додати використані кольори
Additional Plug-ins Folder Папка додаткових модулів
Plug-in Instruction Budget Бюджет інструкцій модулів
Additional Fonts Folder Папка додаткових шрифтів
Adjust Adjoining Width Points Налаштувати суміжні точки ширини
Incoming Вхідна
Can't render this file because it is too large.
+1
View File
@@ -157,6 +157,7 @@
Add Used Colors Thêm các màu đã dùng
Additional Fonts Folder Thư mục phông bổ sung
Additional Plug-ins Folder Thư mục plug-in bổ sung
Plug-in Instruction Budget Ngân sách lệnh của plug-in
Adjust Adjoining Width Points Điều chỉnh các điểm chiều rộng kề nhau
Incoming Phía vào
Outgoing Phía ra
Can't render this file because it is too large.
+1
View File
@@ -90,6 +90,7 @@
Add to Swatches 添加到色板
Add Used Colors 添加已用颜色
Additional Plug-ins Folder 附加增效工具文件夹
Plug-in Instruction Budget 增效工具指令预算
Additional Fonts Folder 附加字体文件夹
Adjust Adjoining Width Points 调整相邻宽度点
Incoming 入侧
Can't render this file because it is too large.
+1
View File
@@ -99,6 +99,7 @@
Add to Swatches 新增至色票
Add Used Colors 新增使用中的顏色
Additional Plug-ins Folder 額外的增效模組資料夾
Plug-in Instruction Budget 增效模組指令預算
Additional Fonts Folder 額外的字體資料夾
Adjust Adjoining Width Points 調整相鄰寬度點
Incoming 入側
Can't render this file because it is too large.
+23
View File
@@ -20,6 +20,29 @@ fn marquee_selection_choices_are_saved_from_preferences() {
assert!(text.contains("Drag Direction"), "{text}");
}
/// Plug-ins & Scratch Disks › Plug-in Instruction Budget: shown with its choices, applied by OK,
/// saved with the UI state and read back from it when the app starts again.
#[test]
fn plugin_instruction_budget_shows_applies_and_restores() {
let mut a = app();
open(&mut a, Some("Plug-ins & Scratch Disks"));
let text = crate::tests_labels::painted_text(&mut a, |a, ui| show(a, ui.ctx()));
assert!(text.contains("Plug-in Instruction Budget") && text.contains("Normal"), "{text}");
a.ui.dialog.as_mut().unwrap().fields.insert("pluginInstructionBudget".into(), json!("large"));
confirm(&mut a).unwrap();
assert_eq!(a.session.prefs.plugin_instruction_budget, vectorcraft_engine::PluginBudget::Large);
let saved: Value = serde_json::from_slice(&serde_json::to_vec(&a.ui).unwrap()).unwrap();
assert_eq!(saved["engine_prefs"]["pluginInstructionBudget"], json!("large"));
let mut b = app();
b.ui.engine_prefs = saved["engine_prefs"].clone();
restore(&mut b);
assert_eq!(b.session.prefs.plugin_instruction_budget, vectorcraft_engine::PluginBudget::Large);
// A saved value this version doesn't offer reads as Normal, and the other preferences stay.
b.ui.engine_prefs = json!({"keyboardIncrement": 4, "pluginInstructionBudget": 7});
restore(&mut b);
assert_eq!((b.session.prefs.plugin_instruction_budget, b.session.prefs.keyboard_increment), (vectorcraft_engine::PluginBudget::Normal, 4.0));
}
#[test]
fn geometric_snapping_is_a_saved_smart_guides_preference() {
let mut a = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
+5
View File
@@ -11924,6 +11924,10 @@ no file, and an import opens no document). A filter whose manifest asks for a he
`plugin.inspect {path | dataBase64}` entry) needs a person's approval, and `plugin.install` refuses `allowHeavy: true`
from a request. `plugin.run`
runs it where it is called, so the call may take minutes; `notifications/cancelled` stops it.
The preference `pluginInstructionBudget` (`normal`, the default, or `large`; `prefs.set` refuses any other value)
sets the instructions every object filter run gets: Large gives a light filter 250 M instructions instead of 50 M,
plus 4,000 per input byte either way, with its 60 s time budget unchanged; a heavy filter keeps its own budget with
either value. The next `plugin.run` or plug-in command uses the value set ([plug-ins](plugins.md#instruction-budget-preference)).
A plug-in whose manifest lists permissions (`permissions` in its `plugin.inspect` entry, with `needsApproval: true`)
needs a person's approval too, and `plugin.install` refuses `grant: [permission]` from a request. With a desktop
app connected, `ui.installPlugin` opens the approval dialog and returns `{pending: "pluginInstall"}`; `answer_dialog`,
@@ -12016,6 +12020,7 @@ Disable and Continue can't save the plug-in it turns off, this launch skips it a
{"name":"run_command","arguments":{"command":"plugin.setEnabled","params":{"id":"org.example.wobble","enabled":true}}}
{"name":"run_command","arguments":{"command":"plugin.install","params":{"path":"/plugins/desaturate.wasm"}}}
{"name":"run_command","arguments":{"command":"plugin.run","params":{"id":"org.vectorcraft.example.desaturate","params":{"amount":60}}}}
{"name":"run_command","arguments":{"command":"prefs.set","params":{"key":"pluginInstructionBudget","value":"large"}}}
{"name":"run_command","arguments":{"command":"effect.apply","params":{"effect":"plugin.org.example.wobble","params":{"size":4}}}}
{"name":"run_command","arguments":{"command":"document.open","params":{"path":"/tmp/plot.hpgl","importer":"plugin.org.example.hpgl"}}}
{"name":"run_command","arguments":{"command":"plugin.org.example.tidy.grow","params":{"by":3}}}
+17 -1
View File
@@ -126,7 +126,7 @@ defaults):
| Module size | 32 MiB | rejected |
| Linear memory | 512 MiB per instance (input and parameters: at most half) | `memory.grow` returns -1; oversized input or initial memory fails |
| Output | 64 MiB of JSON | `Limit("output size")` |
| Instructions (fuel) | 50 M per call + 4,000 per input byte for `vc_run`; a [heavy filter](#heavy-filters) 1 G + 4,000 per byte; an export or import 10 G + 4,000 per byte | `Limit("instruction budget")` |
| Instructions (fuel) | 50 M per call + 4,000 per input byte for `vc_run`; an object filter with the [Large instruction budget](#instruction-budget-preference) 250 M + 4,000 per byte; a [heavy filter](#heavy-filters) 1 G + 4,000 per byte; an export or import 10 G + 4,000 per byte | `Limit("instruction budget")` |
| Wall clock | 60 s per filter run, 5 s per live-effect run, 300 s per heavy filter run, export or import (checked every 20 M instructions; the web build reads the page's `performance.now()`) | `Limit("time budget")` |
| Import input | 128 MiB of the file (`vectorcraft_plugins::import::MAX_INPUT_BYTES`) | the file doesn't open; a larger file named by `path` is not read past that |
| Call depth | 1,024 frames | trap |
@@ -136,6 +136,22 @@ An export runs where the export runs: with Background Export on, on the export's
plug-in between two of those 20 M-instruction slices; nothing is written then. An import stops the same way when the
open it runs in is cancelled, and nothing opens then.
### Instruction budget preference
Preferences › Plug-ins & Scratch Disks › Plug-in Instruction Budget (`pluginInstructionBudget`, VectorCraft's own
setting) sets the instructions each object filter run gets, from the app, `plugin.run`, a plug-in's commands, scripts
and MCP alike:
- **Normal** (`normal`, the default): the limits in the table above, 50 M + 4,000 per input byte.
- **Large** (`large`): 250 M + 4,000 per input byte (`vectorcraft_plugins::LARGE_FUEL`, 5 times Normal). The 60 s time
budget, the memory, output and call depth limits stay as they are.
A [heavy filter](#heavy-filters) keeps its 1 G and 300 s with either choice. Live effects, exporters and importers keep
their own budgets. A change applies to the next run of every installed filter, without installing it again. Cancel and
the time budget stop a run between two 20 M-instruction slices with either choice. `prefs.set {key:
"pluginInstructionBudget", value}` takes `normal` or `large` (or the labels Normal and Large) and refuses any other
value; a saved preferences file with another value reads as Normal.
### Live effects while a document opens
While the app draws a document on screen, the live-effect runs of its first view share a 2,000 ms budget
+1
View File
@@ -2426,6 +2426,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- **Changed plug-in gradients lose spot plates (G17):** a gradient that a filter or importer changes loses each stop's swatch link, tint and process `plates` together, in fills and strokes, and keeps the stop's color, offset, opacity and midpoint; a gradient returned unchanged keeps all three. Regressions: `crates/plugins/src/objects/tests.rs` (`changed_gradient_fill_and_stroke_drop_spot_plates`, `unchanged_gradient_paint_keeps_spot_plates`). Scores and hours unchanged.
- **Plug-in data kept with the document (G17):** a filter writes JSON of at most 1 MiB with `documentData` (one undo step with its objects; `null` removes it) and reads it back in `_context.documentData`, which no other filter is given. It is the document's foreign data (`unknown.pluginData`, by plug-in id), as the perspective grid is, so the native file keeps it with no section of its own; an exporter is given the whole document, so it can read every plug-in's. Regressions: `crates/engine/src/tests/plugins.rs`, `crates/engine/tests/plugin_export.rs` (the exporter), `crates/doc/src/plugin_data.rs`, `crates/plugins/src/objects/tests.rs`. Scores and hours unchanged.
- **Heavy filter plug-ins (G17):** a filter's manifest may ask for `"budget": "heavy"`: 1 G instructions (20 times a light run's) and 300 s a run, for routing, packing or simulation. Install Plug-in… and File › Open ask the user first, `plugin.install` needs `allowHeavy: true` (`plugin.inspect` tells beforehand), the Additional Plug-ins Folder skips such filters, and the plug-in store keeps the answer. Its dialog has no Preview; the app runs it on a thread of its own with a progress window (Cancel, Continue in Background) and applies the result as `plugin.run` with the same parameters, one undo step, unless the document or the plug-in changed meanwhile. Regressions: `crates/plugins/tests/abi.rs`, `crates/plugins/src/manifest.rs`, `crates/engine/src/tests/plugins.rs`, `crates/ui-egui/src/tests/plugin_runs.rs`. Scores and hours unchanged.
- **Plug-in instruction budget preference (G17, VectorCraft's own setting):** Preferences › Plug-ins & Scratch Disks › Plug-in Instruction Budget (`pluginInstructionBudget`) is Normal by default, which keeps the 50 M instructions a light filter run gets, or Large, which gives each object filter run 250 M plus the 4,000 per input byte, with the 60 s time budget, Cancel and the other limits unchanged. A heavy filter keeps its 1 G and 300 s with either choice; live effects, exporters and importers keep their own budgets. A change applies to the next run of an installed filter; `prefs.set` refuses any other value, and a saved file with another value reads as Normal. Regressions: `crates/plugins/tests/abi.rs`, `crates/engine/src/tests/plugins.rs`, `crates/engine/src/tests/prefs.rs`, `crates/ui-egui/src/prefs_dialog/tests.rs`. Scores and hours unchanged.
- **Safe Mode for plug-ins (G17):** `vectorcraft --safe-mode` and `vectorcraft-cli --safe-mode <subcommand>` start without plug-ins. When a launch stopped while a plug-in was loading or drawing its first live effect, the next launch names that plug-in, without saying it caused the stop, and offers Disable and Continue, Start Normally or Start in Safe Mode. Help › Safe Mode lists the disabled plug-ins with Enable on Re-launch, which takes effect at the next launch, and the app bar and the window title show Safe Mode. The help page (https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf, pages 65 to 69) describes the same choice between diagnosing and starting normally, a Safe Mode with the problem item off and the rest of the app working, and turning the item back on at the next launch. In Safe Mode no plug-in loads or runs, and a live-effect plug-in draws its object's geometry unchanged while the object keeps the effect, which the Appearance panel marks "(Safe Mode)" with the plug-in's id in its tooltip and `effect.list` marks `skipped`; Expand Appearance refuses such an object. The web build keeps no plug-ins between page loads and has no marker. Each desktop launch with preferences keeps a marker in the `Launch` folder next to them; `vectorcraft-cli` and a desktop launch without preferences keep none, so a stop there leads to no choice at the next launch. Disabled plug-ins are listed in `Plug-ins/disabled.json`. `plugin.safeMode` reports Safe Mode and the disabled plug-ins, and `plugin.setEnabled` changes the list. Regressions: `crates/plugins/src/safe_mode.rs`, `crates/plugins/tests/safe_mode.rs`, `crates/engine/tests/plugin_safe_mode.rs`, `crates/ui-egui/tests/safe_mode.rs`. Scores and hours unchanged.
- **Hang report and Copy Troubleshooting Info:** when the desktop app's interface thread stays in one part of a frame for 3 s (VectorCraft's own value), a watching thread writes a hang report to the log and to `logs/hang-report-<process id>.txt`, and removes the file when the interface answers again. A later launch that finds a report no process holds writes it to the log, keeps it as `logs/hang-report.1.txt` and, unless another start-up message is showing, says so in the status bar. Help › Copy Troubleshooting Info (`help.copyTroubleshootingInfo`) copies the platform facts, the recent commands and frame times, and the reports of this session and the last one. Regressions: `apps/vectorcraft/src/hang_watch/tests.rs`, `crates/ui-egui/src/hang_beacon.rs`, `crates/ui-egui/src/troubleshooting.rs`. Scores and hours unchanged.
- **A disabled plug-in whose update stays in the store is turned on:** when `plugin.install` writes a module that lists permissions to the `Plug-ins` folder, its grant can't be written, and the folder can't be returned to the old module (or, on a first install, the new module can't be removed), the folder holds the new module, so a disabled plug-in is turned on, by id and by stored file, as for any install the folder holds. The old grant, or none, doesn't cover the new module, so the next start skips it until it is approved. Regressions: `crates/engine/src/tests/plugins.rs`. Scores and hours unchanged.