Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 06-10-2018, 04:46 PM   #1
ausbaxter
Human being with feelings
 
Join Date: Apr 2016
Posts: 39
Default Windows (10) Reaper GUI updates blocking reaper.defer() calls

So I haven't spent as much time as I may need to, and do not understand windows vs mac under the hood well enough to know if this is just a windows limitation, but here it goes.

It looks like when reaper updates gui elements, for example when a user moves an item, it blocks calls to reaper.defer().

I caught this when moving some defer editing scripts over to mac, the performance was leaps and bounds better than on windows. These scripts rely on getting item info as the user start's their edit. Because defer is blocked for a short time when gui elements are redrawn (i'm guessing this is the case) the efficacy of the scripts are dependant on the user's edit speed.

Here's a comparison of defer calls on Mac and Windows. (both are captured after various edit commands, moves/trims etc.)

Just want to call attention to this in case this is something that can be resolved, or it'd be nice to know if this is a known limitation of deferred scripts on windows.

This is the code:

Code:
call_count = 0

function main()
    call = os.time()
    call_count = call_count + 1
    
    if call ~= prev_call then
        reaper.ShowConsoleMsg("Defer Call:\t" .. call .. "\tCall Count:\t" .. call_count .. "\n")
        call_count = 0
    end
    
    prev_call = call 
    reaper.defer(main)   
end

reaper.atexit(function()gfx.quit()end)

main()
----------------------------------------------------------------------------------------------------------------------------------------------------------------------

On windows you can see that the # of calls severely diminishes when user activity increases with some of the calls being blocked for over a second.

Windows:


----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Mac is very stable at 31-32 calls per second

Mac:
ausbaxter is offline   Reply With Quote
Old 06-11-2018, 07:23 AM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Try it with reaper.time_precise() - I had to stop using os.time() for my GUI stuff because it behaves different on Mac vs Windows (8 here) and some controls weren't receiving user updates properly.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 06-11-2018, 07:37 AM   #3
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,175
Default

Also - I don't know the difference between calling ShowConsoleMsg on Windows and on Mac - but on Windows - it is really really slow - and should probably not be used when trying to do any performance related testing.

Would be better to write the output to a string or table then output the results to the console after the test period.

Because if the Mac console output is quicker then it's not really a fair or accurate comparison between the two. Of course if Mac console is just as slow - then ignore me
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   Reply With Quote
Old 06-11-2018, 07:50 AM   #4
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by lb0 View Post
Would be better to write the output to a string or table then output the results to the console after the test period.
ShowConsoleMsg is a huge performance on hog on Windows, absolutely. Even just a few basic "starting function ___" messages in a GUI script will bog things down, and if you start printing too many it will freeze all of Reaper until the script times out.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna 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 04:50 AM.


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