Device registration broken with certain actions present in profiles

Moving discussion from #OpenDeck on Arch Linux
70 Replies
ninjadev64
ninjadev64OP2mo ago
So this is what I've understood @Percy_Ikana: - 2.whatever you were on before works - 2.2.1 from AUR is working fine - 2.3.0 AppImage is blank (could you try the steps in #25?) - 2.3.1/-git device does not register That means 13860cd (a commit you said worked https://discord.com/channels/1143819637897834571/1143819638732505130/1306023316959789117) and below are safe, bug introduced somewhere later than that I think that seeing whether 2.3.0 works or not would be the next most productive step, and if you can't get the AppImage working in a couple of minutes then building from source will be helpful anyway so that we can go back commit by commit very easily (git reset --hard HEAD~1) Commands to run from source: - git clone --recurse-submodules https://github.com/ninjadev64/OpenDeck.git - cd OpenDeck - deno install - deno task tauri build @Terrorwolf as well sorry
Terrorwolf
Terrorwolf2mo ago
@Percy_Ikana Is it all Materialdeck actions or just certain? And with what configuration of the button does it happen?
ninjadev64
ninjadev64OP2mo ago
While terrorwolf's suggestion is not unhelpful I do request that we first try determining the opendeck commit in which this started occurring because it will be much easier for me to resolve the issue that way - ultimately, this is an opendeck bug and not a material deck one, whether certain MD actions work or not may simply be coincidence, as well as the fact that this issue almost certainly concerns other plugins
Terrorwolf
Terrorwolf2mo ago
I am just asking, because with my pc its not yet reproducible and I had hoped that maybe with a specific setting I can force the problem. Maybe we can also find a helpful information when my VM is ready.
Percy_Ikana
Percy_Ikana2mo ago
Yes, when I get back to my computer I will attempt to get 2.3.0 working, (what is #25 in this context) Thank you both for helping
Terrorwolf
Terrorwolf2mo ago
no problem
ninjadev64
ninjadev64OP2mo ago
#25 is GitHub issue 25, it's to do with blank windows
Percy_Ikana
Percy_Ikana2mo ago
Thanks.
ninjadev64
ninjadev64OP2mo ago
The only difference I can see between your 2.2.1 profiles and 2.3.1 ones are that the font sizes have become numbers and that the base64 image URLs have been saved as files instead Which all seems normal I think when you have time to build from source, I can ask you to put various debugging statements in places and we can see what happens
Percy_Ikana
Percy_Ikana2mo ago
I will let you know.
Percy_Ikana
Percy_Ikana2mo ago
the env var did not help
No description
Percy_Ikana
Percy_Ikana2mo ago
Im on an AMD GPU Okay thats all I have time for its 0:30
ninjadev64
ninjadev64OP2mo ago
Try removing the && before attempting building from source
Terrorwolf
Terrorwolf2mo ago
Hi, Sorry I have not been sucessful in Piping my Streamdeck to my VM. I will try again after the Holidays. (Propably 26th or 27th.)
Percy_Ikana
Percy_Ikana2mo ago
building fails due to appimage problems
Percy_Ikana
Percy_Ikana2mo ago
No description
ninjadev64
ninjadev64OP2mo ago
NO_STRIP=true deno task tauri build Many other arch users have had that work
Percy_Ikana
Percy_Ikana2mo ago
okay, that worked, how do I launch it lol just from the built releases? Okay, built app image works, and shows the same behavior so tomorrow ill step back through commits and see what works
ninjadev64
ninjadev64OP2mo ago
Cool
Terrorwolf
Terrorwolf2mo ago
The white screen also happened to me in my VM right now. I needed to add my User to a Group to properly pipe my streamdeck into my vm. Proplem does not happen on my live system. Next step to rule kde out, i will try to setup endeavouros with gnome. Forgot to mention: tried on both systems with tge newest appimage from github. Same Problem with EOS and GNOME.
ninjadev64
ninjadev64OP2mo ago
You are using the WEBKIT_DISABLE_DMABUF_RENDERER variable or whatever it is right?
Terrorwolf
Terrorwolf2mo ago
at my live system, yes should I also try it in my vm?
Percy_Ikana
Percy_Ikana2mo ago
9e3d675 is the last commit that works wait im a moron one sec 574559b is the last commit that works
ninjadev64
ninjadev64OP2mo ago
Oh, interesting? It’ll be a deadlock with the INSTANCES mutex then That is not where I thought the bug would be, but that’s very helpful, thanks - I should be able to fix it next time I get time Out all day today though Yes of course, that’s the first step to try when the window is blank
Percy_Ikana
Percy_Ikana2mo ago
Just let me know when to test something! Absolutely no rush, it's holidays and I at least have a working version atm
ninjadev64
ninjadev64OP2mo ago
When you've got time, could you try adding: - drop(categories); after line 53 (creating line 54) of src-tauri/src/store/profiles.rs - surrounding lines 81 to 97 of src-tauri/src/plugins/mod.rs in {}, id est adding a { on line 80 and a } on line 98 I'm not sure it will fix the problem but it's worth a try you can do that on the latest source or the 0e191c2 source, but latest is probably better
Percy_Ikana
Percy_Ikana2mo ago
No description
Percy_Ikana
Percy_Ikana2mo ago
Have a good christmas!
Terrorwolf
Terrorwolf2mo ago
Merry Christmas
ninjadev64
ninjadev64OP2mo ago
Oh, whoops, also add .clone() to the end of line 53 (before the semicolon) Merry Christmas!
Percy_Ikana
Percy_Ikana2mo ago
No description
ninjadev64
ninjadev64OP2mo ago
what lol gimme a sec
Percy_Ikana
Percy_Ikana2mo ago
no worries lol I just got back to a computer to try it
ninjadev64
ninjadev64OP2mo ago
this laptop is taking ages to get itself together not at my normal pc ok, i was trying to avoid actually building the thing, but i guess i am now because the ide error stuff isnt working try moving the .clone between the .values() and the .flatten() or don't until i check that it works ok replace the line with this let actions = categories.values().flatten().map(|x| x.to_owned()).collect::<Vec<_>>(); instead
Percy_Ikana
Percy_Ikana2mo ago
I need to just learn rust
ninjadev64
ninjadev64OP2mo ago
its usually not too hard as the ide tells u immediately that u borrowed smth wrong but harder when that's gone, like it is for me rn
Percy_Ikana
Percy_Ikana2mo ago
Yhea, I know Cpp, although its been years since I worked with it so its a "I just need to actually learn how rust functions" Ive been lazy af recently and I only use Python for my job so I havent looked at anything else also you are right It did not fix the issue it did build though!
ninjadev64
ninjadev64OP2mo ago
ah shame im tryna get this thing to even run on the laptop rn, some macos-related tauri panic how about replacing lines 57 to 59 with true?
let keep_instance = |instance: &ActionInstance| -> bool {
true
};
let keep_instance = |instance: &ActionInstance| -> bool {
true
};
like that
Percy_Ikana
Percy_Ikana2mo ago
all of this?
No description
ninjadev64
ninjadev64OP2mo ago
with this yea
Percy_Ikana
Percy_Ikana2mo ago
am I keeping or removing the drop and clone?
ninjadev64
ninjadev64OP2mo ago
shouldn't matter keep it
Percy_Ikana
Percy_Ikana2mo ago
Kay
ninjadev64
ninjadev64OP2mo ago
then if that works, undo it and replace just !futures::executor::block_on(crate::plugins::is_plugin_registered(&instance.action.plugin)) with true
Percy_Ikana
Percy_Ikana2mo ago
That worked
ninjadev64
ninjadev64OP2mo ago
both?
Percy_Ikana
Percy_Ikana2mo ago
sorry just the first about to test the second its working
ninjadev64
ninjadev64OP2mo ago
nice, also annoying
Percy_Ikana
Percy_Ikana2mo ago
test
test
Okay I was trying to send you the code as is, but discord wont let me, thanks
pub async fn get_profile_store_mut(&mut self, device: &DeviceInfo, id: &str) -> Result<&mut Store<Profile>, anyhow::Error> {
#[cfg(target_os = "windows")]
let path = PathBuf::from("profiles").join(&device.id).join(id.replace('/', "\\"));
#[cfg(not(target_os = "windows"))]
let path = PathBuf::from("profiles").join(&device.id).join(id);
let path = path.to_str().unwrap();

if self.stores.contains_key(path) {
Ok(self.stores.get_mut(path).unwrap())
} else {
let default = Profile {
id: id.to_owned(),
keys: vec![None; (device.rows * device.columns) as usize],
sliders: vec![None; device.encoders as usize],
};

let mut store = Store::new(path, &config_dir(), default).context(format!("Failed to create store for profile {}", path))?;

let categories = crate::shared::CATEGORIES.read().await;
let actions = categories.values().clone().flatten().collect::<Vec<_>>();
let plugins_dir = config_dir().join("plugins");
let keep_instance = |instance: &ActionInstance| -> bool {
instance.action.plugin == "opendeck"
|| (plugins_dir.join(&instance.action.plugin).exists()
&& (true || actions.iter().any(|v| v.uuid == instance.action.uuid)))
};
for slot in store.value.keys.iter_mut() {
if let Some(instance) = slot {
if !keep_instance(instance) {
*slot = None;
} else if let Some(children) = &mut instance.children {
children.retain_mut(|child| keep_instance(child));
}
}
}
store.save()?;

self.stores.insert(path.to_owned(), store);
Ok(self.stores.get_mut(path).unwrap())
}
}
pub async fn get_profile_store_mut(&mut self, device: &DeviceInfo, id: &str) -> Result<&mut Store<Profile>, anyhow::Error> {
#[cfg(target_os = "windows")]
let path = PathBuf::from("profiles").join(&device.id).join(id.replace('/', "\\"));
#[cfg(not(target_os = "windows"))]
let path = PathBuf::from("profiles").join(&device.id).join(id);
let path = path.to_str().unwrap();

if self.stores.contains_key(path) {
Ok(self.stores.get_mut(path).unwrap())
} else {
let default = Profile {
id: id.to_owned(),
keys: vec![None; (device.rows * device.columns) as usize],
sliders: vec![None; device.encoders as usize],
};

let mut store = Store::new(path, &config_dir(), default).context(format!("Failed to create store for profile {}", path))?;

let categories = crate::shared::CATEGORIES.read().await;
let actions = categories.values().clone().flatten().collect::<Vec<_>>();
let plugins_dir = config_dir().join("plugins");
let keep_instance = |instance: &ActionInstance| -> bool {
instance.action.plugin == "opendeck"
|| (plugins_dir.join(&instance.action.plugin).exists()
&& (true || actions.iter().any(|v| v.uuid == instance.action.uuid)))
};
for slot in store.value.keys.iter_mut() {
if let Some(instance) = slot {
if !keep_instance(instance) {
*slot = None;
} else if let Some(children) = &mut instance.children {
children.retain_mut(|child| keep_instance(child));
}
}
}
store.save()?;

self.stores.insert(path.to_owned(), store);
Ok(self.stores.get_mut(path).unwrap())
}
}
there.
ninjadev64
ninjadev64OP2mo ago
ok, one more thing to try gimme a sec
Percy_Ikana
Percy_Ikana2mo ago
should I reset to base for this, or continue adding?
ninjadev64
ninjadev64OP2mo ago
you can reset
Percy_Ikana
Percy_Ikana2mo ago
I just want to make sure we are on the same code
ninjadev64
ninjadev64OP2mo ago
you can re-add the second one of these though
Percy_Ikana
Percy_Ikana2mo ago
mod.rs 80-98 has been surrounded.
ninjadev64
ninjadev64OP2mo ago
then, replace that keep_instance function with this
let registered = crate::plugins::registered_plugins().await;
let keep_instance = |instance: &ActionInstance| -> bool {
instance.action.plugin == "opendeck"
|| (plugins_dir.join(&instance.action.plugin).exists() && (!registered.contains(&instance.action.plugin) || actions.iter().any(|v| v.uuid == instance.action.uuid)))
};
let registered = crate::plugins::registered_plugins().await;
let keep_instance = |instance: &ActionInstance| -> bool {
instance.action.plugin == "opendeck"
|| (plugins_dir.join(&instance.action.plugin).exists() && (!registered.contains(&instance.action.plugin) || actions.iter().any(|v| v.uuid == instance.action.uuid)))
};
and replace mod.rs is_plugin_registered function with this one
pub async fn registered_plugins() -> Vec<String> {
INSTANCES.lock().await.keys().map(|x| x.to_owned()).collect()
}
pub async fn registered_plugins() -> Vec<String> {
INSTANCES.lock().await.keys().map(|x| x.to_owned()).collect()
}
hopefully works 🤞 discord is bugging Your message could not be delivered. This is usually because you don't share a server with the recipient or the recipient is only accepting direct messages from friends. You can see the full list of reasons here: https://support.discord.com/hc/en-gb/articles/360060145013
Percy_Ikana
Percy_Ikana2mo ago
yhea im getting that as well for half of my messages
ninjadev64
ninjadev64OP2mo ago
i was just gonna send the whole thing to make it easier for u
Percy_Ikana
Percy_Ikana2mo ago
it helps if I save the file before building... Its fine, im not as good as you but I am a software dev lol
ninjadev64
ninjadev64OP2mo ago
lol they really need to make the rust compiler faster this shit takes ages
Percy_Ikana
Percy_Ikana2mo ago
I need to check how many cores its using also, its working
ninjadev64
ninjadev64OP2mo ago
oh awesome that can just be the fix then
Percy_Ikana
Percy_Ikana2mo ago
the only parts of this code I ever really knew was the display part So what was broken, and how did this fix it?
ninjadev64
ninjadev64OP2mo ago
so what the buggy code had was an is_plugin_registered function to check whether or not a plugin was registered, and that locked the mutex every time it was called but instead i just pulled some stuff out of that function so that it could be called only once in the parent function that was calling it, locking and then unlocking the mutex quickly which seems to be preventing the deadlock please do just run it again to check it isnt a race condition
Percy_Ikana
Percy_Ikana2mo ago
Threading! I did, ive restarted it a couple times and made profile edits between
ninjadev64
ninjadev64OP2mo ago
cool cool
Percy_Ikana
Percy_Ikana2mo ago
Ill be using this for DnD (pathfinder, but im not fighting 18 years of calling thursday nights dnd) today, I will let you know if I experience any issues.
ninjadev64
ninjadev64OP2mo ago
awesome, have fun
Percy_Ikana
Percy_Ikana2mo ago
Enjoy the rest of your holiday!

Did you find this page helpful?