Skip to content

Commit

Permalink
Allow "main thread effects" to be rendered while trying to aquire the…
Browse files Browse the repository at this point in the history
… layer lock to make it match the behavior of the non-main thread effects.

Of course, the best option is to just use a Mac where there aren't any main thread effects which cause these issues.
  • Loading branch information
dkulp committed Jan 20, 2024
1 parent e300902 commit 82493f8
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 92 deletions.
20 changes: 10 additions & 10 deletions xLights/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RenderEvent {
SettingsMap *settingsMap;
PixelBufferClass *buffer;
bool *ResetEffectState;
bool returnVal{ true };
int returnVal{ -1 };
bool suppress{ false };
};

Expand Down Expand Up @@ -1069,16 +1069,13 @@ void xLightsFrame::RenderEffectOnMainThread(RenderEvent *ev) {
std::unique_lock<std::mutex> lock(ev->mutex);

// validate that the effect still exists as this could be being processed after the effect was deleted
if (_sequenceElements.IsValidEffect(ev->effect))
{
if (_sequenceElements.IsValidEffect(ev->effect)) {
ev->returnVal = RenderEffectFromMap(ev->suppress, ev->effect,
ev->layer,
ev->period,
*ev->settingsMap,
*ev->buffer, *ev->ResetEffectState, false, ev);
}
else
{
*ev->buffer, *ev->ResetEffectState, false, ev) ? 1 : 0;
} else {
wxASSERT(false);
}
ev->signal.notify_all();
Expand Down Expand Up @@ -1694,6 +1691,10 @@ bool xLightsFrame::AbortRender(int maxTimeMS, int* numThreadsAborted)
{
static log4cpp::Category &logger_base = log4cpp::Category::getInstance(std::string("log_base"));
static bool inAbort = false;
if (renderProgressInfo.empty()) {
//nothing to abort, return quickly
return true;
}
if (inAbort) {
return false;
}
Expand All @@ -1710,7 +1711,6 @@ bool xLightsFrame::AbortRender(int maxTimeMS, int* numThreadsAborted)
}
}
}

int maxLoops = maxTimeMS;
maxLoops /= 10; //doing a 10ms sleep
//must wait for the rendering to complete
Expand Down Expand Up @@ -2180,15 +2180,15 @@ bool xLightsFrame::RenderEffectFromMap(bool suppress, Effect* effectObj, int lay

CallAfter(&xLightsFrame::RenderMainThreadEffects);
if (event->signal.wait_for(lock, std::chrono::seconds(10)) == std::cv_status::no_timeout) {
retval = event->returnVal;
retval = event->returnVal == 1;
}
else {
logger_base.warn("HELP!!!! Frame #%d render on model %s (%dx%d) layer %d effect %s from %dms (#%d) to %dms (#%d) timed out 10 secs.", b->curPeriod, (const char*)buffer.GetModelName().c_str(), b->BufferWi, b->BufferHt, layer, (const char*)reff->Name().c_str(), effectObj->GetStartTimeMS(), b->curEffStartPer, effectObj->GetEndTimeMS(), b->curEffEndPer);
printf("HELP!!!! Frame #%d render on model %s (%dx%d) layer %d effect %s from %dms (#%d) to %dms (#%d) timed out 10 secs.\n", b->curPeriod, (const char*)buffer.GetModelName().c_str(), b->BufferWi, b->BufferHt, layer, (const char*)reff->Name().c_str(), effectObj->GetStartTimeMS(), b->curEffStartPer, effectObj->GetEndTimeMS(), b->curEffEndPer);

// Give it one more chance
if (event->signal.wait_for(lock, std::chrono::seconds(60)) == std::cv_status::no_timeout) {
retval = event->returnVal;
retval = event->returnVal == 1;
}
else {
logger_base.warn("DOUBLE HELP!!!! Frame #%d render on model %s (%dx%d) layer %d effect %s from %dms (#%d) to %dms (#%d) timed out 70 secs.", b->curPeriod, (const char*)buffer.GetModelName().c_str(), b->BufferWi, b->BufferHt, layer, (const char*)reff->Name().c_str(), effectObj->GetStartTimeMS(), b->curEffStartPer, effectObj->GetEndTimeMS(), b->curEffEndPer);
Expand Down
Loading

0 comments on commit 82493f8

Please sign in to comment.