Old 08-17-2019, 08:43 AM   #1
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default Issue with SWS and custom script

Posting this here as well:

I'm using Justins SWS build on Windows 10 with Reaper 5.981 dev0814 and there's a problem with "SWS/BR actions that play from mouse cursor position and solo track under mouse for the duration".

Executing it once will work flawlessly, but having done that, the GUI goes nuts (artefacts and Reaper becomes unusable). Executing it a second time creates a time selection and solo does not work anymore. Also, the "play cursor" disappears.

Have a look at the GIF:

https://nextcloud.stephanroemer.net/...2AqSDQcYgwT4Yo


Bug report on GitHub:
https://github.com/reaper-oss/sws/issues/1180
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom

Last edited by _Stevie_; 08-17-2019 at 10:17 AM.
_Stevie_ is offline   Reply With Quote
Old 08-17-2019, 09:40 AM   #2
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Hmm I can't duplicate this, post your reaper.ini and .rpp file?
Justin is offline   Reply With Quote
Old 08-17-2019, 09:43 AM   #3
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Here you go:

http://nextcloud.stephanroemer.net/i...c58Dfy2kxrmmWj
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-17-2019, 09:51 AM   #4
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Hmm still working fine here...
Justin is offline   Reply With Quote
Old 08-17-2019, 09:53 AM   #5
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Hmm, will investigate and see what else it could be.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-17-2019, 09:53 AM   #6
puddi
Human being with feelings
 
puddi's Avatar
 
Join Date: Jun 2018
Posts: 375
Default

Seems to be working fine for me in dev0813, FWIW.

Btw, what theme is that? Looks nice
puddi is offline   Reply With Quote
Old 08-17-2019, 09:55 AM   #7
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Will check what happens, when I install the regular SWS version.


That's i Logic 3 from Blankfiles.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-17-2019, 10:11 AM   #8
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

Uhm...what's "justin's sws build?"
__________________
foxyyymusic
foxAsteria is offline   Reply With Quote
Old 08-17-2019, 10:17 AM   #9
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Okay, found it. It seems to be triggered by one of my scripts.

I'm using a custom script to mimic a different play/pause behavior.
Pause is essentially stop + move editor cursor to play cursor.

So, executing the SWS action, followed by a stop from this script, triggers that behavior.

Code:
function NoUndoPoint() end 

playstate = reaper.GetPlayState() -- get play state of the transport
if playstate > 0 then -- when play state is greater 0 (play, pause, record)
	reaper.Main_OnCommand(40434, 0) -- View: Move edit cursor to play cursor
	reaper.Main_OnCommand(1016, 0) -- Transport: Stop
else 
	reaper.Main_OnCommand(1007, 0) -- Transport: Play
end

reaper.defer(NoUndoPoint)
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-17-2019, 10:36 AM   #10
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by _Stevie_ View Post
Okay, found it. It seems to be triggered by one of my scripts.

I'm using a custom script to mimic a different play/pause behavior.
Pause is essentially stop + move editor cursor to play cursor.

So, executing the SWS action, followed by a stop from this script, triggers that behavior.

Code:
function NoUndoPoint() end 

playstate = reaper.GetPlayState() -- get play state of the transport
if playstate > 0 then -- when play state is greater 0 (play, pause, record)
	reaper.Main_OnCommand(40434, 0) -- View: Move edit cursor to play cursor
	reaper.Main_OnCommand(1016, 0) -- Transport: Stop
else 
	reaper.Main_OnCommand(1007, 0) -- Transport: Play
end

reaper.defer(NoUndoPoint)
Got it, thanks.
Justin is offline   Reply With Quote
Old 08-17-2019, 10:40 AM   #11
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Quote:
Originally Posted by Justin View Post
Got it, thanks.
Awesome!


@FoxAsteria: the devs did some changes in the latest Reaper (better performance for a huge amount of tracks). But they had to change the way tracks are seen (every track used to have its own hwnd, if I'm not mistaken). SWS Mouse actions were still depending on this earlier method. So Justin fixed some code in SWS to make this work again. Justin's code will be incorporated in the next SWS release.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-17-2019, 11:04 AM   #12
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,255
Default

Oh la la. More performance always a good thing. Thx!
__________________
foxyyymusic
foxAsteria is offline   Reply With Quote
Old 08-17-2019, 11:54 AM   #13
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

This bug actually should affect 5.981/release SWS too.
Justin is offline   Reply With Quote
Old 08-17-2019, 11:55 AM   #14
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Yes, sorry, forgot to mention, I tested it with the current SWS, as well.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-17-2019, 12:13 PM   #15
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Ahh, OK, so what happens here is:

1) Your ReaScript triggers stop
2) reaper_sws gets notified of playback stopping -- notifies REAPER to stop doing UI updates, and installs a timer to re-enable them later
3) Your ReaScript terminates. REAPER sees the "do not perform UI updates" flag is still set, clears it (assuming the script left it on).
4) reaper_sws's timer runs, decrementing the UI update flag, causing an incorrect state.

This is a bit tricky (the whole notion of this flag is a bit fragile). The cleanest fix would probably be to disable the disabling+timer in sws...
Justin is offline   Reply With Quote
Old 08-17-2019, 12:34 PM   #16
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Thanks for explaining, Justin!
That's tricky indeed.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-17-2019, 01:25 PM   #17
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by _Stevie_ View Post
Thanks for explaining, Justin!
That's tricky indeed.
As a workaround, maybe you can use a custom action rather than a reascript to
stop? Or something...
Justin is offline   Reply With Quote
Old 08-17-2019, 01:26 PM   #18
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Could I use a cycle action or what that trigger the same effect?
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-17-2019, 01:29 PM   #19
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by _Stevie_ View Post
Could I use a cycle action or what that trigger the same effect?
I forget (afk) is there a play-state meta action? Err looks like not. Pause might have the behavior you want, too. Or maybe you can always do “move edit cursor to play cursor” before calling play/stop
Justin is offline   Reply With Quote
Old 08-17-2019, 01:31 PM   #20
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Pretty much, yes. You can do a:

If next action is on "Transport: Play"
do "Transport: stop"


I will just try it out.


EDIT: yep, that works!
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 08-23-2019, 09:02 AM   #21
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

@Justin

I also run often into problems with PreventUIRefresh, mostly when I decrement the counter to prevent uirefresh, but another function incremented it to prevent uirefresh, so it's not prevented anymore.

Could it help, if a script would not in/decrement the counter but rather set/unset a token to
register "I want to prevent UI refresh"?
And it gets reset after script is finished, if still set?

That way, there's only a way to do it with more consistency, means, no matter how many functions use UIRefresh, they can only set it once.
So maybe only an internal counter for every script instance, incremented/decremented automatically by the Un/SetToken-function.
But not "globally", as I think it is currently now.
That way, we could only do "PreventUIRefresh2(true/false)" or something, not messing around with the counter directly.

No idea, if that would work for extension-plugins, or if this would cause scripts, though...

If I understood the problem at all
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...

Last edited by Meo-Ada Mespotine; 08-23-2019 at 09:08 AM.
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-23-2019, 10:12 AM   #22
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

I don't think it's a problem, as long as plugins/scripts use preventuirefresh as designed, which is to say, only prevent UI refresh for as short of a time as possible. E.g. if you're going to do a batch of operations, prevent refresh while doing that batch, but enable it immediately after. In this case there is no issue.

In fact it might make sense to make it not even a counter, but just a flag, so that the consequence of misuse is just slightly reduced performance, which could be spotted and fixed, rather than it getting into an undesirable state...
Justin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:50 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.