You are not logged in.

Read the FAQ and Knowledge Base before posting.
We won't make a 3DS/2DS emulator.



#1 2021-07-06 23:28:32

StormBurnX
Member
From: Arizona, USA
Registered: 2021-07-06
Posts: 7
Website

Emulator lags/stutters/hangs when mouse cursor hovers over window...

...and while a secondary program is also reading/writing the mouse location.

Ok, so this is a spicy one for y'all devs, and as a beginner programmer who knows enough to know how wildly complex some of this stuff can be, I'll do my best to explain the issue I've noticed as well as the various troubleshooting I've done to eliminate potential problem sources.

So, the TL;DR: I'm using a GlovePIE script to check when the mouse is over the DeSmuME window for [reasons]. While the script is checking the mouse position, or writing a new mouse position, DeSmuME seems to throw a tantrum that it isn't allowed to access the mouse at the same time as a different program, and will simply hang on whatever frame it's on and the audio currently in the buffer until the mouse is free.

This wouldn't be such a big deal, except it seems to do this every time the mouse is accessed, so if I turn on the script and start moving the mouse in rapid circles (so that it's moving significantly/rapidly on every frame) DeSmuME can lag SO MUCH that it gives up and emergency dumps the audio buffer, presumably because it's hanging too hard. (Or at least that's what the console says.)

I was trying out the new version of DeSmuME that lets you increase your internal render resolution for 3D scenes because [reasons] and I thought, ah, perhaps this is just an issue with this unstable build, so I went back to the 6-year-old stable build (0.9.11) and lo and behold, it has the same issue.

I have re-run my script at a lower framerate (1Hz) and every time there's a mouse check, there's a tiny bit of lag in DeSmuME if the mouse is hovering over DeSmuME, regardless of if the window is in focus. This seems to be particularly bad when I'm using DirectInput api calls to access the mouse, as even just rotating it in slow circles causes the emulator to immediately seize up, whereas when using things other than dinput seem to require a lot more rapid mouse movement to trigger stutters/slowdowns.

I assumed my script was just eating up way too much processing, but no matter how much I slow it down (even down to 0.2Hz) the issue persists at the exact moment that the mouse position is read or accessed.

I thought perhaps it was just the scripting software in general, but if I comment out all lines related to the mouse position, the issue resolves. Similarly, if I comment out the parts only relevant to writing a new mouse position OR the parts only relevant to reading the mouse position, the issue still persists.

I have 3 metroid prime carts and have dumped the roms from two of them, the issue exists regardless of which rom I use.

I have tried two versions of DeSmuME, the issue exists regardless of which version I use.

I have tried two versions of the scripting tool, the issue exists regardless of which version I use.

I have also tried no$gba and melonDS but the issue does not exist in them.

-

I reckon this has something to do with how DeSmuME requests info on whether the mouse is hovering over the window, as this occurs even if the mouse is merely hovering over the titlebar of the window - it's not exclusive to hovering over the rendered game area. After troubleshooting about 19 different api methods for having my script read the mouse position and having all of them either report no info back, or trigger this odd DeSmuME-only issue, I think the next goal is to try the RetroArch DeSmuME core, but the whole point of using DeSmuME in the first place was due to the internal resolution increase function, and I don't know if that's available in the retroarch core yet (but even with the resolution increase disabled, the issue persists).

I should also note that I've gone through, just for troubleshooting's sake, and toggled every single setting that had a checkbox, as well as adjusted a few miscellaneous other things, and simply put, even with all DeSmuME settings inverted (minus the ones that are necessary for the game to boot) the issue still persists, which once again nudges me in the direction of thinking it has something to do with the underlying methods for accessing the mouse.

I can record a short screencap showing what I'm referring to if it helps, currently this is a non-issue for normal users but the [reasons] referred to earlier are that I'm trying to build a PrimeHack-style script that analyzes the window size and position, calculates where the bounding box for the touchsceen aiming area is, and then automatically 'lifts' and snaps the mouse to the opposite side when you are aiming, to provide a more natural and intuitive continuous mouse-movement-based-aiming system. I know this is stupid, and it would be best done by forking the emulator and modifying it directly, but that is WAY beyond my technical level. I screencapped a video demoing the very basic mouse relocation method and that code is a little outdated, but you can see the animations on the top/left DS screen stuttering and lagging while I'm moving the mouse cursor continuously over the DeSmuME window while the script is running.

-

update: I tested both versions of DeSmuME in retroarch and while switching to raw mouse input in retroarch's settings mostly mitigated the issue, it still persisted periodically, unfortunately. Could not reproduce the issue on melonDS.

Last edited by StormBurnX (2021-07-07 00:08:41)

Offline

#2 2021-07-09 02:04:40

zeromus
Radical Ninja
Registered: 2009-01-05
Posts: 6,169

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

Unhappily, your having reproduced the issue in retroarch proves that it has nothing to do with desmume. Its method for interacting with the operating system mouse is 100% different from ours. So that's 2/4 success rate for your scripting method. The only thing odd that desmume does is try to play mind games with the stylus input APIs on windows. You could try making a build and commenting that out. but that code would not even be running in retroarch (yet maybe retroarch does something similar). Desmume doesn't do anything particular when the mouse moves. It just reads the mouse position every frame (which is read from the OS in unique ways by retroarch and desmume) and that may indicate motion or it may not; there's no difference in either case. Happy debugging.

Offline

#3 2021-07-09 09:03:10

StormBurnX
Member
From: Arizona, USA
Registered: 2021-07-06
Posts: 7
Website

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

Ah, that's a major oof sad I couldn't reproduce the issue in iDeaS, no$gba, no$gba debug version, or melonDS, only in desmume (the two builds I tried) and retroarch desmume (the two cores available).

I have not been able to check if it's an issue only in metroid or in desmume in general, though as a scripter not a programmer I doubt I'll be able to provide much information or help regarding the issue either way. Thanks for the timely response.

Offline

#4 2021-07-09 17:49:34

zeromus
Radical Ninja
Registered: 2009-01-05
Posts: 6,169

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

gimme the script youre using and whatever instructions I need to use it without having to figure out how to use that software and i'll see what's going on in desmume

Offline

#5 2021-07-09 23:05:42

StormBurnX
Member
From: Arizona, USA
Registered: 2021-07-06
Posts: 7
Website

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

https://www.dropbox.com/s/5ud6hf75cw3w4 … k.zip?dl=0

https://youtu.be/kVNC6fvdt5k

I've tossed the copy of desmume I was using + the config file (switches the layout to horizontal and sets ` as the pause button), along with glovepie + the script itself. Additionally I've recorded a very basic one-take demo video to illustrate the issues I'm running into.

Things I forgot to mention in the video: you'll likely need to open glovepie.exe, then use the File > Open menu to navigate to the script. I already have .pie script files associated with glovepie on my computer, so this step was not present in the video.

Additionally, if I comment out the lines that include reading the cursor position or writing the cursor position, DeSmuME goes back to 'normal', that is to say, only the normal amount of lagging/glitching/hanging occurs. Only when GlovePIE is actively reading or writing the mouse position does this exacerbation occur within DeSmuME.

Hope this helps! I know it's a wildly niche issue and I reckon it's possible I'm the only person in the world with this specific complaint. There's a community of folks who play the Prime Trilogy via the Dolphin emulator with a mod called PrimeHack, which is a fork of Dolphin specifically to add native mouse/keyboard controls to the Prime Trilogy, and some people have a small interest in reproducing the same concept for Metroid Prime: Hunters on DS, with DeSmuME being the most reliable emulator for everyone.

In other words, only like ~4 people on the entire internet even care about this, and I'm the only one of us that cares enough to even try and make a script to do this, so it's REALLY NOT A BIG DEAL if this is not resolved. Please do not feel pressured to 'fix' this. It is purely a random little hobby project. smile

(If I knew how to do real programming I'd be learning how to use github and how to fork/clone/commit and all those fancy words. A decade ago you helped me find palib and devkitpro and I started dipping my toes into programming via the DS homebrew scene, but alas, that's about as far as my programming skills ever got, hence why I'm writing a script to manipulate the mouse rather than doing this "properly" and making a version of DeSmuME specifically for this project. You're a huge inspiration and I've got mad respect for the work you've done and continue to do!)

Offline

#6 2021-07-10 01:03:15

zeromus
Radical Ninja
Registered: 2009-01-05
Posts: 6,169

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

Works fine for me. I can't perceive any irregularities. This is a problem with your system configuration. That the problem happens in retroarch and desmume both is a COMPLETE COINCIDENCE. Try disabling any streaming software, gaming enhancements ("game mode"), etc. You may need to disable some windows DPI adjustment. Also try changing desmume's config > display method and choosing a different desmume 3d renderer option. Any of those may change the manner in which your OS cripples windows with cursors over them. You may also search for how to disable DWM. I bet that's involved somehow.

Offline

#7 2021-07-10 01:29:08

StormBurnX
Member
From: Arizona, USA
Registered: 2021-07-06
Posts: 7
Website

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

I do audio production work on this machine so normally all of those things are entirely removed/disabled to ensure the most stable DAW performance but I'll run through your suggestions and see if anything changes. Thanks for testing this and letting me know, if it's just my machine that's a huge relief for sure! I thought an i9 9900 could handle a little DS emulation but who knows, a setting might be wonky, this is windows after all

Last edited by StormBurnX (2021-07-10 01:29:37)

Offline

#8 2021-07-10 02:04:19

StormBurnX
Member
From: Arizona, USA
Registered: 2021-07-06
Posts: 7
Website

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

Turned off all the startup programs and whatnot on my machine, closed everything that seemed safe to close in Task Manager, ensured as few things as possible could even potentially bother desmume, and gave it a go.

> Try disabling any streaming software
Even without OBS open to record it happening, the issue still happens

> Try disabling any gaming enhancements ("game mode"), etc.
The closest thing to that crap on my computer is the software for my NVidia graphics card, so I killed that as well

> You may need to disable some windows DPI adjustment
Everything related to those settings is on default/"Recommended", aka there's no scaling or HiDPI mode going on

> Also try changing desmume's config > display method and choosing a different desmume 3d renderer option
It happens in all three of them, as well as when it's simply set to 'none'

> You may also search for how to disable DWM. I bet that's involved somehow.
Unluckily for me, I can't even find this in services.msc nor task manager, so I reckon it's either not even running or hiding under a different name.

I even tried switching my monitors from 75Hz down to a more "normal" 60Hz to see if this would resolve the issue but alas. Gonna fiddle with some other settings but I'm mostly out of ideas for what to change in Windows to try and get this working. (changing GPU acceleration settings and disabling iGPU didn't work, those were the last ideas I had)

I'll see if either of my roommates' laptops have the same issue though. Assuming this weird bug ONLY happens on my computer, I have no problem finishing development and publishing it for others to use, even if I can't personally benefit from it myself.

Probably final update: I can't get it to have this issue on my shitty Intel Atom "laptop" that's just a glorified tablet, which is the weakest computer in our entire house. If that thing can manage to run DeSmuME + GlovePIE without issue then I think it's safe to say it's just some random curse I have where my real computer can't do things correctly, alas.

Last edited by StormBurnX (2021-07-10 02:25:08)

Offline

#9 2021-07-10 03:56:57

zeromus
Radical Ninja
Registered: 2009-01-05
Posts: 6,169

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

It's a random curse. Next time you reformat I suggest testing desmume immediately and then checking it after everything you install to figure out what's breaking it. I neglected to mention upgrading/downgrading your GPU drivers might be relevant. Also, I run windows 7. It's possible desmume is broken this way for every nvidia user on windows 10, as of a certain win10 patch and/or nvidia driver version, or something like that. Whenever MSFT tries to "enhance" windows for games it runs the risk of breaking other games (same goes for GPU driver enhancements). And presently MSFT doesn't have personnel with the requisite interests (they would all rather be working for apple but are 2nd rate) or a corporate mandate to give a shit about anything that's not selling tablets, selling apps, or selling azure.

Offline

#10 2021-07-10 04:23:52

StormBurnX
Member
From: Arizona, USA
Registered: 2021-07-06
Posts: 7
Website

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

> Also, I run windows 7.
That makes sense, given the "disable DWM" thing, which is simply not an option in 8/10.

> It's possible desmume is broken this way for every nvidia user on windows 10
The intel atom netbook (I think it's a Lenovo Yoga or something?) doesn't have a graphics chipset in it, so I had my roomate test in his laptop with a 10th gen intel chip and a GTX 1660 (I'm a 9th gen intel chip and RTX 2070). I think that rules out the "every nvidia user on windows 10" issue but they're on a laptop, I'm on a desktop, I have no idea which version of the graphics driver (or windows) they're on, so. 


> Whenever MSFT tries to "enhance" windows for games it runs the risk of breaking other games
Ironically, before the spectre/meltdown/heartbleed era (in which Intel CPUs got mega nuked via windows security updates, anywhere from 5-40% performance drops) I had saved a backup copy of Windows 10, and I install that version on older machines that would be crippled by the "more secure" versions of Windows, but I don't have any spare drives with it preinstalled to test this desmume/glovepie issue on. I'll bugtest with some folks in the PrimeHack discord but (assuming you've only tested this on one machine) 4 out of 5 machines work fine, with only my desktop having the issue. I've been doing some hackintoshing which required flipping a heck of a lot of BIOS settings and it's possible one of those has bugged out some kind of cpu/gpu related thing, but I don't feel like digging through all that right now to check.

(Incidentally I also spun up two of my VMs to try and test this in, but the mouse cursor access is different in those, and failed altogether, rather than causing problems, so I'm not counting those as actual machines)

Mega thanks, again, for your thoughts and feedback smile

Last edited by StormBurnX (2021-07-10 08:01:03)

Offline

#11 2021-08-07 08:05:01

StormBurnX
Member
From: Arizona, USA
Registered: 2021-07-06
Posts: 7
Website

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

man, I got excited about a new post, but it's just more spam. huzzah.

Offline

#12 2022-04-09 11:01:07

aquila
Member
Registered: 2022-04-09
Posts: 2

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

made an account to say that most gaming mice these days come at a default 1000hz polling rate. lowering this to 250hz completely solved this problem. some games/apps have issues with high polling rates, and desmume is no exception. my guess is there is an error with the way mouse activity is read, which only becomes apparent with higher polling rates

Last edited by aquila (2022-04-09 11:04:54)

Offline

#13 2022-04-10 00:31:53

zeromus
Radical Ninja
Registered: 2009-01-05
Posts: 6,169

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

Are you the same person posting on github? What OS are you using? I can't see any reason at all why mouse polling would affect the windows desmume.

Offline

#14 2022-10-18 11:25:23

putrzop
Member
Registered: 2022-10-17
Posts: 1

Re: Emulator lags/stutters/hangs when mouse cursor hovers over window...

you'll likely need to open glovepie.exe, then use the File > Open menu to navigate to the script.  techzpod download mobdro

Last edited by putrzop (2022-10-20 09:31:50)

Offline

Board footer

Powered by FluxBB