Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potato farming #3230

Draft
wants to merge 72 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
36e24a9
Add `util.callok()`. Use instead of `coro.resume()`; ditch coro.lua.
nat-goodspeed Oct 1, 2024
b185a55
Add cheap Lua LL.yield() function to pacify infinite loop detection.
nat-goodspeed Oct 1, 2024
acd8c46
Remove obsolete destringize_f() function.
nat-goodspeed Oct 1, 2024
ae3d19e
WIP: use leap.eventstream() in place of special listener object.
nat-goodspeed Oct 17, 2024
766911c
Merge branch 'develop' into nat/lua-eventstream
nat-goodspeed Oct 24, 2024
9abf183
Merge branch 'nat/lua-eventstream' into nat/lua-eventstream
nat-goodspeed Oct 24, 2024
dea629a
Replace timers.Timer(delay, 'wait') API with timers.sleep(delay).
nat-goodspeed Oct 24, 2024
d4fdf12
Forgot return value.
nat-goodspeed Oct 24, 2024
83d92df
Merge branch 'develop' of secondlife/viewer into nat/lua-eventstream
nat-goodspeed Dec 4, 2024
0fc5efe
Revert "WIP: use leap.eventstream() in place of special listener obje…
nat-goodspeed Dec 5, 2024
d28d825
Add Eliza.lua script
nat-goodspeed Dec 5, 2024
d9fd012
Defend LLListener from multiple instances confusing each other.
nat-goodspeed Dec 5, 2024
434c053
Streamline LLAgent.getNearbyMumbleList() returns.
nat-goodspeed Dec 5, 2024
322c3d8
Remove inspect.lua's fiber.yield() calls.
nat-goodspeed Dec 5, 2024
c5a88a8
When an iterative timer function stops, cancel the source timer.
nat-goodspeed Dec 5, 2024
9eb8813
Detect the "[LUA]" message prefix exactly at the beginning.
nat-goodspeed Dec 5, 2024
b8eebe2
Add a test for LL.setdtor(result_view(...)).
nat-goodspeed Dec 5, 2024
c15416b
Add liz-demo.lua script.
nat-goodspeed Dec 5, 2024
6aa0cab
Add Lua api to upload local textures; add snapshot preview demo script
maxim-productengine Dec 6, 2024
528a0fe
Mac build fix
nat-goodspeed Dec 6, 2024
64becf8
Merge branch 'maxim/potato' into nat/lua-liz
nat-goodspeed Dec 6, 2024
e7c2266
Update liz-demo to actually sit on the chair
nat-goodspeed Dec 6, 2024
362a890
Reintroduce fiber.yield() to inspect.lua to display larger tables.
nat-goodspeed Dec 6, 2024
4e35101
Update to luau 0.654
maxim-productengine Dec 6, 2024
c37286e
Lua api for changing quality settings
maxim-productengine Dec 9, 2024
73e5a70
move api for setting quality to lluilistener
maxim-productengine Dec 9, 2024
59f8387
Add a number of functions to util.lua.
nat-goodspeed Dec 10, 2024
c3d688d
Add a TODO to ~LuaState(). We should run atexit() funcs if we can,
nat-goodspeed Dec 10, 2024
6ca8939
When a coroutine dies with an exception, report its what() if we can.
nat-goodspeed Dec 10, 2024
ea81f5f
When LL_DEBUG("Lua") is enabled, reduce LuaRequirePath spam.
nat-goodspeed Dec 10, 2024
ca52962
Adapt test_nearby_avatars.lua for changed LLAgent returned data.
nat-goodspeed Dec 10, 2024
c8e919c
Use new util.class() for leap.WaitFor class hierarchy.
nat-goodspeed Dec 10, 2024
82a9ae8
Add LLListener:inline() that suspends caller until done.
nat-goodspeed Dec 10, 2024
c74991e
Simplify liz-demo.lua script. Also extend it a little.
nat-goodspeed Dec 10, 2024
de2fe5c
A module's local helper function must precede its consumers.
nat-goodspeed Dec 10, 2024
986f46c
add demo script with setting the follow cam
maxim-productengine Dec 10, 2024
69899e7
Delete testmod.lua; was used for early testing.
nat-goodspeed Dec 10, 2024
dcf04e8
Merge pull request #3258 from secondlife/nat/potato0
nat-goodspeed Dec 11, 2024
c0dc46c
Don't leave a util.class() subclass with a 'base' class attribute.
nat-goodspeed Dec 11, 2024
ba4fefd
Recast Queue, WaitQueue and ErrorQueue using util.class().
nat-goodspeed Dec 11, 2024
29134e3
Recast LLListener, UI.Floater and timers.Timer to use util.class().
nat-goodspeed Dec 11, 2024
e469a2e
Update comments for util.class() and util.classctor().
nat-goodspeed Dec 11, 2024
a45631a
In liz-demo.lua, make camera face avatar during Eliza chat.
nat-goodspeed Dec 11, 2024
7b2eee7
Merge pull request #3261 from secondlife/nat/potato1
nat-goodspeed Dec 11, 2024
60136ba
more commands in test_LLChatListener.lua
vir-linden Dec 11, 2024
d745d10
Merge pull request #3264 from secondlife/vir/potato
vir-linden Dec 11, 2024
f77c51b
Add LLListener:next_event(): one-shot inline(); use for liz-demo.lua.
nat-goodspeed Dec 11, 2024
1128d3d
Add LLDebugSettings.getGraphicsQuality()
nat-goodspeed Dec 11, 2024
973236c
Add LLAgent.localToGlobal(), globalToLocal() conversions.
nat-goodspeed Dec 11, 2024
efa6238
Add photo-demo.lua: look around TextureTest and take pictures
nat-goodspeed Dec 11, 2024
61ceead
Merge branch 'maxim/potato' of secondlife/viewer into nat/potato2
nat-goodspeed Dec 11, 2024
a67555c
When user closes floater early, abort the run.
nat-goodspeed Dec 11, 2024
3dc88e8
Revert "Add LLDebugSettings.getGraphicsQuality()"
nat-goodspeed Dec 11, 2024
ca5b1e4
Re-add LLDebugSettings.getGraphicsQuality() using get() feature.
nat-goodspeed Dec 11, 2024
b7332b7
Merge pull request #3268 from secondlife/nat/potato2
nat-goodspeed Dec 12, 2024
174ad13
save snapshot to temp directory
maxim-productengine Dec 12, 2024
f029cf8
Merge pull request #3271 from secondlife/maxim/potato_tmp
nat-goodspeed Dec 12, 2024
24c98c0
Couple minor cosmetic tweaks to photo-demo.lua
nat-goodspeed Dec 12, 2024
c31356c
one more snapshot demo script
maxim-productengine Dec 12, 2024
8417f48
For release, don't try to post Linux installer -- it fails.
nat-goodspeed Dec 12, 2024
f555060
Use Maxim's workaround for odd camera zoom at low graphics quality
nat-goodspeed Dec 12, 2024
51451c2
Widen loafloater_preview_demo.xml combo_boxes for "High +"
nat-goodspeed Dec 12, 2024
60bbe1b
Merge branch 'maxim/potato' into nat/potato3
nat-goodspeed Dec 12, 2024
4e2f241
Suppress two views with weird zoom behavior at low graphics quality.
nat-goodspeed Dec 12, 2024
8d8c5b0
Instead of commenting out Linux posting, delete it in build.yaml.
nat-goodspeed Dec 12, 2024
98e7970
Merge pull request #3273 from secondlife/nat/potato3
nat-goodspeed Dec 12, 2024
84f31fd
Fix a bug in ScriptCommand.
nat-goodspeed Dec 19, 2024
76d7079
Merge branch 'develop' of secondlife/viewer into maxim/potato
nat-goodspeed Dec 19, 2024
86f0bb6
Merge pull request #3313 from secondlife/nat/potato-dev0
nat-goodspeed Dec 20, 2024
f4ff498
Lua api for toggling Render types, features and info display
maxim-productengine Jan 4, 2025
9438c86
post-merge script fix
maxim-productengine Jan 6, 2025
050da01
Lua api for resetting frame stats; add decloud time to the logged stats
maxim-productengine Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions autobuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1595,11 +1595,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>e48f291e2eeb1dbab39f26db5ac9b4c2b2d1c57d</string>
<string>422b988f8d543a90b9b16f88c7bc2a367e19cdc6</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://github.com/secondlife/3p-luau/releases/download/v0.638-r2/luau-0.638.0-r2-darwin64-10356321602.tar.zst</string>
<string>https://github.com/secondlife/3p-luau/releases/download/v0.654/luau-0.654.0-darwin64-12204676273.tar.zst</string>
</map>
<key>name</key>
<string>darwin64</string>
Expand All @@ -1609,11 +1609,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>3a797d8dae685b25ca787111a370b99d9e57d77c</string>
<string>2db068085eeefb3c91b28b769a39fa901c4e796a</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://github.com/secondlife/3p-luau/releases/download/v0.638-r2/luau-0.638.0-r2-linux64-10356321602.tar.zst</string>
<string>https://github.com/secondlife/3p-luau/releases/download/v0.654/luau-0.654.0-linux64-12204676273.tar.zst</string>
</map>
<key>name</key>
<string>linux64</string>
Expand All @@ -1623,11 +1623,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>a8857313496622134b00899141bbe6542f754164</string>
<string>f62eb31ac1a2407033100e424c4b361382c7bc12</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://github.com/secondlife/3p-luau/releases/download/v0.638-r2/luau-0.638.0-r2-windows64-10356321602.tar.zst</string>
<string>https://github.com/secondlife/3p-luau/releases/download/v0.654/luau-0.654.0-windows64-12204676273.tar.zst</string>
</map>
<key>name</key>
<string>windows64</string>
Expand Down
12 changes: 10 additions & 2 deletions indra/llcommon/llcoros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,19 @@ void LLCoros::toplevel(std::string name, callable_t callable)
// viewer will carry on.
LOG_UNHANDLED_EXCEPTION("coroutine " + name);
}
catch (...)
catch (const std::exception& exc)
{
// Stash any OTHER kind of uncaught exception in the rethrow() queue
// to be rethrown by the main fiber.
// to be rethrown by the main fiber. Report the cause.
LL_WARNS("LLCoros") << "Capturing uncaught exception in coroutine "
<< name << ": " << exc.what() << LL_ENDL;
LLCoros::instance().saveException(name, std::current_exception());
}
catch (...)
{
// We can't even tell what kind of exception this is. Stash it in the
// rethrow() queue to be rethrown by the main fiber.
LL_WARNS("LLCoros") << "Capturing unknown uncaught exception in coroutine "
<< name << LL_ENDL;
LLCoros::instance().saveException(name, std::current_exception());
}
Expand Down
19 changes: 19 additions & 0 deletions indra/llcommon/lua_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,11 @@ LuaState::~LuaState()
{
// If we're unwinding the stack due to an exception, don't bother trying
// to call any callbacks -- either Lua or C++.
// TODO: It's a problem that we don't call LL.atexit() functions when the
// script is canceled. We use atexit() internally to clean up the
// LuaListener, if any, also any ResultSet objects created by the script.
// Canceling and then rerunning a script can potentially crash the viewer
// due to a dangling LuaListener.
if (std::uncaught_exceptions() != 0)
return;

Expand Down Expand Up @@ -1030,6 +1035,20 @@ void LuaState::check_interrupts_counter()
}
}

void LuaState::yield()
{
// We want Lua scripts to call fiber.yield() often to avoid being killed
// by our infinite loop detection (above). But calling llcoro::suspend()
// every time would be a disincentive, since that actually pauses the C++
// coroutine running the Lua script for a frame. This yield() method
// judiciously calls llcoro::suspend() when it seems warranted.
if (mInterrupts >= INTERRUPTS_MAX_LIMIT/2)
{
llcoro::suspend();
mInterrupts = 0;
}
}

/*****************************************************************************
* atexit()
*****************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions indra/llcommon/lua_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class LuaState

void set_interrupts_counter(S32 counter);
void check_interrupts_counter();
void yield();

int push_debug_traceback();

Expand Down
51 changes: 31 additions & 20 deletions indra/llcommon/scriptcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ScriptCommand::ScriptCommand(const std::string& command, const LLSD& path,
"\"'", // either kind of quotes
"\\"); // backslash escape
// search for args[0] on paths
if (search(args[0], path, basepath))
if (search(basepath, path, args[0]))
{
// The first token is in fact the script filename. Now that we've
// found the script file, we've consumed that token. The rest are
Expand All @@ -48,7 +48,7 @@ ScriptCommand::ScriptCommand(const std::string& command, const LLSD& path,
// Maybe that's because there are spaces in the original pathname that
// were neither quoted nor escaped? See if we can find the whole original
// command line string.
if (search(command, path, basepath))
if (search(basepath, path, command))
{
// Here we found script, using the whole input command line as its
// pathname. Discard any parts of it we mistook for command-line
Expand Down Expand Up @@ -83,34 +83,45 @@ ScriptCommand::ScriptCommand(const std::string& command, const LLSD& path,
LL_WARNS("Lua") << mError << LL_ENDL;
}

bool ScriptCommand::search(const fsyspath& script, const LLSD& paths, const fsyspath& base)
bool ScriptCommand::search(const fsyspath& base, const LLSD& paths, const fsyspath& script)
{
if (! paths.size())
{
return checkone(base, "", script);
}
for (const auto& path : llsd::inArray(paths))
{
// If a path is already absolute, (otherpath / path) preserves it.
// Explicitly instantiate fsyspath for every string conversion to
// properly convert UTF-8 filename strings on Windows.
fsyspath absscript{ base / fsyspath(path.asString()) / script };
bool exists;
try
{
exists = std::filesystem::exists(absscript);
}
catch (const std::filesystem::filesystem_error& exc)
if (checkone(base, path, script))
{
mError = stringize("Can't check existence: ", exc.what());
LL_WARNS("Lua") << mError << LL_ENDL;
return false;
}
if (exists)
{
this->script = absscript.string();
return true;
}
}
return false;
}

bool ScriptCommand::checkone(const fsyspath& base, const LLSD& path, const fsyspath& script)
{
// If a path is already absolute, (otherpath / path) preserves it.
// Explicitly instantiate fsyspath for every string conversion to
// properly convert UTF-8 filename strings on Windows.
fsyspath absscript{ base / fsyspath(path.asString()) / script };
bool exists;
try
{
exists = std::filesystem::exists(absscript);
}
catch (const std::filesystem::filesystem_error& exc)
{
mError = stringize("Can't check existence: ", exc.what());
LL_WARNS("Lua") << mError << LL_ENDL;
return false;
}
if (! exists)
return false;
this->script = absscript.string();
return true;
}

std::string ScriptCommand::error() const
{
return mError;
Expand Down
3 changes: 2 additions & 1 deletion indra/llcommon/scriptcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class ScriptCommand
std::string error() const;

private:
bool search(const fsyspath& script, const LLSD& path, const fsyspath& base);
bool search(const fsyspath& base, const LLSD& paths, const fsyspath& script);
bool checkone(const fsyspath& base, const LLSD& path, const fsyspath& script);

std::string mError;
};
Expand Down
10 changes: 0 additions & 10 deletions indra/llcommon/stringize.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,4 @@ T destringize(std::basic_string<CHARTYPE> const & str)
return val;
}

/**
* destringize_f(str, functor)
*/
template <typename CHARTYPE, typename Functor>
void destringize_f(std::basic_string<CHARTYPE> const & str, Functor const & f)
{
std::basic_istringstream<CHARTYPE> in(str);
f(in);
}

#endif /* ! defined(LL_STRINGIZE_H) */
17 changes: 17 additions & 0 deletions indra/llui/llluafloater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@ LLLuaFloater::LLLuaFloater(const LLSD &key) :
setTitle(event["value"].asString());
}, llsd::map("value", LLSD()));

mDispatchListener.add("add_item", "", [this](const LLSD &event)
{
LLComboBox *ctrl = getChild<LLComboBox>(event["ctrl_name"].asString());
if(ctrl)
{
ctrl->add(event["name"].asString(), event["value"]);
}
}, requiredParams);
mDispatchListener.add("select_by_value", "", [this](const LLSD &event)
{
LLComboBox *ctrl = getChild<LLComboBox>(event["ctrl_name"].asString());
if(ctrl)
{
ctrl->setSelectedByValue(event["value"], true);
}
}, requiredParams);

mDispatchListener.add("get_value", "", [ctrl_lookup](const LLSD &event)
{
return ctrl_lookup(event, [](LLUICtrl *ctrl, const LLSD &event) { return llsd::map("value", ctrl->getValue()); });
Expand Down
10 changes: 10 additions & 0 deletions indra/newview/llappviewerlistener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// external library headers
// other Linden headers
#include "llappviewer.h"
#include "llviewerstats.h"
#include "workqueue.h"

LLAppViewerListener::LLAppViewerListener(const LLAppViewerGetter& getter):
Expand All @@ -52,6 +53,10 @@ LLAppViewerListener::LLAppViewerListener(const LLAppViewerGetter& getter):
add("forceQuit",
"Quit abruptly",
&LLAppViewerListener::forceQuit);

add("resetFrameStats",
"Reset frame related stats",
&LLAppViewerListener::resetFrameStats);
}

void LLAppViewerListener::userQuit(const LLSD& event)
Expand All @@ -77,3 +82,8 @@ void LLAppViewerListener::forceQuit(const LLSD& event)
LL::WorkQueue::getInstance("mainloop")->post(
[appviewer=mAppViewerGetter()]{ appviewer->forceQuit(); });
}

void LLAppViewerListener::resetFrameStats(const LLSD& event)
{
LLViewerStats::instance().resetFrameStats();
}
1 change: 1 addition & 0 deletions indra/newview/llappviewerlistener.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class LLAppViewerListener: public LLEventAPI
void userQuit(const LLSD& event);
void requestQuit(const LLSD& event);
void forceQuit(const LLSD& event);
void resetFrameStats(const LLSD& event);

LLAppViewerGetter mAppViewerGetter;
};
Expand Down
11 changes: 7 additions & 4 deletions indra/newview/llfloaterpreference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,12 @@ void LLFloaterPreference::refreshEnabledGraphics()
}
}

void LLFloaterPreference::setGraphicsQuality(U32 level)
{
LLFeatureManager::getInstance()->setGraphicsLevel(level, true);
refreshEnabledGraphics();
}

void LLFloaterPreference::onClickClearCache()
{
LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache);
Expand Down Expand Up @@ -1362,10 +1368,7 @@ void LLFloaterPreference::onCommitWindowedMode()

void LLFloaterPreference::onChangeQuality(const LLSD& data)
{
U32 level = (U32)data.asReal();
LLFeatureManager::getInstance()->setGraphicsLevel(level, true);
refreshEnabledGraphics();
refresh();
setGraphicsQuality((U32)data.asReal());
}

void LLFloaterPreference::onClickSetSounds()
Expand Down
2 changes: 2 additions & 0 deletions indra/newview/llfloaterpreference.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver,
// update Show Favorites checkbox
static void updateShowFavoritesCheckbox(bool val);

static void setGraphicsQuality(U32 level);

void processProperties( void* pData, EAvatarProcessorType type ) override;
void saveAvatarProperties( void );
static void saveAvatarPropertiesCoro(const std::string url, bool allow_publish);
Expand Down
12 changes: 4 additions & 8 deletions indra/newview/llluamanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,11 @@ S32 LLLUAmanager::sAutorunScriptCount = 0;
S32 LLLUAmanager::sScriptCount = 0;
std::map<std::string, std::string> LLLUAmanager::sScriptNames;

lua_function(sleep, "sleep(seconds): pause the running coroutine")
lua_function(yield, "yield(): allow other processing to run.")
{
lua_checkdelta(L, -1);
lua_Number seconds = lua_tonumber(L, -1);
lua_pop(L, 1);
llcoro::suspendUntilTimeout(narrow(seconds));
LuaState::getParent(L).set_interrupts_counter(0);
LuaState::getParent(L).yield();
return 0;
};
}

// This function consumes ALL Lua stack arguments and returns concatenated
// message string
Expand Down Expand Up @@ -344,7 +340,7 @@ void LLRequireResolver::findModule()
}

LLSD lib_paths(gSavedSettings.getLLSD("LuaRequirePath"));
LL_DEBUGS("Lua") << "LuaRequirePath = " << lib_paths << LL_ENDL;
LL_DEBUGS_ONCE("Lua") << "LuaRequirePath = " << lib_paths << LL_ENDL;
for (const auto& path : llsd::inArray(lib_paths))
{
// if path is already absolute, operator/() preserves it
Expand Down
Loading
Loading