Update Tauri to v2 and execute only the node graph in native (#2362)

* Migrate tauri app to v2

* Move flake files to sub directory

* Remove unused plugins

* Backport some of the tauri code

* Implement async node graph execution

Only move node runtime to native code

* Always use gpu feature for tauri

* Fix serialization

* Add logging filters

* Enable native window rendering with vello

* Cleanup

* Remove unused editor instance

* Remove changes from vite config

* Remove warnings

* Remove unused files

* Fix most tests

* Cleanup

* Apply frontend lint

* Readd flake.nix

* Fix tests using --all-features

* Code review

* Enable all backends

* Fix monitor node downcast types

* Change debug log to a warning

* Disable shader passthrough

* Cleanup unused imports

* Remove warning

* Update project setup instructions

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Dennis Kobert
2025-04-14 13:43:15 +02:00
committed by GitHub
parent 29479f6e3e
commit 9b23c7e2db
39 changed files with 10429 additions and 2831 deletions

View File

@@ -49,8 +49,8 @@ macro_rules! tagged_value {
}
}
impl<'a> TaggedValue {
/// Converts to a Box<dyn DynAny> - this isn't very neat but I'm not sure of a better approach
pub fn to_any(self) -> DAny<'a> {
/// Converts to a Box<dyn DynAny>
pub fn to_dynany(self) -> DAny<'a> {
match self {
Self::None => Box::new(()),
$( Self::$identifier(x) => Box::new(x), )*
@@ -59,6 +59,16 @@ macro_rules! tagged_value {
Self::EditorApi(x) => Box::new(x),
}
}
/// Converts to a Arc<dyn Any + Send + Sync + 'static>
pub fn to_any(self) -> Arc<dyn std::any::Any + Send + Sync + 'static> {
match self {
Self::None => Arc::new(()),
$( Self::$identifier(x) => Arc::new(x), )*
Self::RenderOutput(x) => Arc::new(x),
Self::SurfaceFrame(x) => Arc::new(x),
Self::EditorApi(x) => Arc::new(x),
}
}
/// Creates a graphene_core::Type::Concrete(TypeDescriptor { .. }) with the type of the value inside the tagged value
pub fn ty(&self) -> Type {
match self {
@@ -84,6 +94,18 @@ macro_rules! tagged_value {
_ => Err(format!("Cannot convert {:?} to TaggedValue", DynAny::type_name(input.as_ref()))),
}
}
/// Attempts to downcast the dynamic type to a tagged value
pub fn try_from_std_any_ref(input: &(dyn std::any::Any)) -> Result<Self, String> {
use std::any::TypeId;
match input.type_id() {
x if x == TypeId::of::<()>() => Ok(TaggedValue::None),
$( x if x == TypeId::of::<$ty>() => Ok(TaggedValue::$identifier(<$ty as Clone>::clone(input.downcast_ref().unwrap()))), )*
x if x == TypeId::of::<RenderOutput>() => Ok(TaggedValue::RenderOutput(RenderOutput::clone(input.downcast_ref().unwrap()))),
x if x == TypeId::of::<graphene_core::SurfaceFrame>() => Ok(TaggedValue::SurfaceFrame(graphene_core::SurfaceFrame::clone(input.downcast_ref().unwrap()))),
_ => Err(format!("Cannot convert {:?} to TaggedValue",std::any::type_name_of_val(input))),
}
}
pub fn from_type(input: &Type) -> Option<Self> {
match input {
Type::Generic(_) => {
@@ -135,16 +157,16 @@ macro_rules! tagged_value {
tagged_value! {
// TODO: Eventually remove this migration document upgrade code
#[cfg_attr(feature = "serde", serde(deserialize_with = "graphene_core::raster::image::migrate_image_frame"))]
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::raster::image::migrate_image_frame"))]
ImageFrame(graphene_core::raster::image::ImageFrameTable<Color>),
// TODO: Eventually remove this migration document upgrade code
#[cfg_attr(feature = "serde", serde(deserialize_with = "graphene_core::vector::migrate_vector_data"))]
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::vector::migrate_vector_data"))]
VectorData(graphene_core::vector::VectorDataTable),
// TODO: Eventually remove this migration document upgrade code
#[cfg_attr(feature = "serde", serde(deserialize_with = "graphene_core::migrate_graphic_group"))]
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::migrate_graphic_group"))]
GraphicGroup(graphene_core::GraphicGroupTable),
// TODO: Eventually remove this migration document upgrade code
#[cfg_attr(feature = "serde", serde(deserialize_with = "graphene_core::migrate_artboard_group"))]
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::migrate_artboard_group"))]
ArtboardGroup(graphene_core::ArtboardGroupTable),
GraphicElement(graphene_core::GraphicElement),
Artboard(graphene_core::Artboard),
@@ -332,7 +354,7 @@ impl<'input> Node<'input, DAny<'input>> for UpcastNode {
type Output = FutureAny<'input>;
fn eval(&'input self, _: DAny<'input>) -> Self::Output {
Box::pin(async move { self.value.clone().into_inner().to_any() })
Box::pin(async move { self.value.clone().into_inner().to_dynany() })
}
}
impl UpcastNode {