<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text -->
<style>.EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; }</style></head>
<body>
<font size="2"><div class="PlainText"><p style="font-size: 10pt; font-family: Calibri, Helvetica, Arial, sans-serif; color: rgb(133, 133, 133);"><span style="font-weight: bolder;">Javier Carrasco</span><br>R&D Engineer<br><span style="font-size: 13.3333px;">Mail: </span><a href="mailto:%7BE-mail%7D" style="text-decoration-line: none; background-color: rgb(255, 255, 255); font-size: 13.3333px;"><font color="#953735">javier.carrasco@wolfvision.net</font></a></p><p style="font-family: Calibri, Helvetica, Arial, sans-serif; color: rgb(133, 133, 133);"><font color="#953735" style="font-size: 13.3333px;"><span style="font-weight: bolder;">WolfVision GmbH</span></font><br style="font-size: 13.3333px;"><span style="font-size: 13.3333px;">Oberes Ried 14 | 6833 Klaus | Österreich</span><br style="font-size: 13.3333px;"><span style="font-size: 13.3333px;">T: </span><a href="tel:+43552352250" style="text-decoration-line: none; font-size: 13.3333px;"><font color="#953735">+43 5523 52250</font></a></p><p style="font-size: 10pt; font-family: Calibri, Helvetica, Arial, sans-serif; color: rgb(133, 133, 133);"><span style="font-size: 13.3333px;">Webpage: </span><a href="https://www.wolfvision.com/" style="background-color: rgb(255, 255, 255); font-size: 13.3333px;"><font color="#953735">www.wolfvision.com</font></a><span style="font-size: 13.3333px;"> | </span><a title="" href="https://www.wolfvision.com/green" style="background-color: rgb(255, 255, 255); font-size: 13.3333px;"><font color="#953735">www.wolfvision.com/green</font></a><span style="font-size: 13.3333px;"></span><br style="font-size: 13.3333px;"><span style="font-size: 8pt;">Firmenbuch / Commercial Register: FN283521v Feldkirch/Austria</span></p><p style="font-size: 10pt; font-family: Calibri, Helvetica, Arial, sans-serif; color: rgb(133, 133, 133);"><a href="https://marketing.wolfvision.com/l/908602/2024-10-24/by7n7" title="" style="background-color: rgb(255, 255, 255); font-family: Arial; font-size: 12px;"><img src="cid:registernow-signatur_ise25_v1_def26d5c-56fe-418c-a169-3703386ee9c5.jpg" border="0" id="0.wayectog05" alt="RegisterNow-Signatur_ISE25_v1.jpg"></a><a href="https://info.wolfvision.com/ise/?utm_source=email&utm_medium=referral&utm_campaign=ise2024&utm_content=signature" title="" style="background-color: rgb(255, 255, 255); font-family: Arial; font-size: 12px;"></a><font color="#858585" face="Calibri, Helvetica, Arial, sans-serif" style="font-size: 12px;"><span style="font-size: 13.3333px;"><br></span></font><span style="color: rgb(33, 37, 41); font-family: Arial; font-size: 12px; font-weight: bolder;"><span style="font-size: 10pt; color: rgb(35, 79, 149);">See our new solutions LIVE in Barcelona at ISE booth 3N500<br></span></span><span style="color: rgb(33, 37, 41); font-size: 13.3333px;"><font color="#234f95"><span style="font-weight: bolder;"><span style="font-family: Arial;">Use our discount code </span><span style="font-family: Arial;">QK7Z38BS</span><span style="font-family: Arial;"> to secure your free ticket </span><a href="https://marketing.wolfvision.com/l/908602/2024-10-24/by7n7" title="" style="font-family: Arial;">here</a><span style="color: rgb(185, 30, 43);"><span style="font-family: Calibri;"> </span></span></span></font></span></p>On 25/10/2024 11:46, Umang Jain wrote:<br>
> Hello Javier<br>
> <br>
> On 25/10/24 2:08 pm, Javier Carrasco wrote:<br>
>> If the camera device is stopped, there may still be requests within<br>
>> 'data->queuedRequests_' that are mistakenly never popped. If this is the<br>
>> case, libcamera terminates with the assertion<br>
>> 'ASSERT(data->queuedRequests_.empty())'.<br>
>><br>
>> Walk over the pending queued requests, destroy the info frames and<br>
>> complete the requests to ensure that no requests are left behind.<br>
>><br>
>> Co-developed-by: Lukas Riezler <lukas.riezler@wolfvision.net><br>
>> Signed-off-by: Lukas Riezler <lukas.riezler@wolfvision.net><br>
>> Signed-off-by: Javier Carrasco <javier.carrasco@wolfvision.net><br>
>><br>
>> ---<br>
>> src/libcamera/pipeline/rkisp1/rkisp1.cpp | 7 +++++++<br>
>> 1 file changed, 7 insertions(+)<br>
>><br>
>> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp<br>
>> b/src/libcamera/pipeline/rkisp1/rkisp1.cpp<br>
>> index c02c7cf3..efa7dbd5 100644<br>
>> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp<br>
>> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp<br>
>> @@ -997,6 +997,13 @@ void PipelineHandlerRkISP1::stopDevice(Camera<br>
>> *camera)<br>
>> << "Failed to stop parameters for " <<<br>
>> camera->id();<br>
>> }<br>
>><br>
>> + while (!data->queuedRequests_.empty()) {<br>
>> + Request *req = data->queuedRequests_.front();<br>
>> + RkISP1FrameInfo *info = data->frameInfo_.find(req);<br>
>> + data->frameInfo_.destroy(info->frame);<br>
>> + completeRequest(req);<br>
>> + }<br>
>> +<br>
> <br>
> We should never do this - if we need to this, there is clearly a bug<br>
> somewhere. stop() makes sure all requests are completed (even with<br>
> status = cancelled)<br>
> <br>
> Refer to PipelineHandler::stop() documentation<br>
> <br>
>> ASSERT(data->queuedRequests_.empty());<br>
> <br>
> What I think is, this is a redundant assert and should be dropped from<br>
> RkISP1PipelineHandler::stopDevice()<br>
> <br>
> We are already in stopDevice() which is called by<br>
> PipelineHandler::stop() - which already has this ASSERT<br>
> <a href="https://eur04.safelinks.protection.outlook.com/?">https://eur04.safelinks.protection.outlook.com/?</a><br>
> url=https%3A%2F%2Fgit.libcamera.org%2Flibcamera%2Flibcamera.git%2Ftree%2Fsrc%2Flibcamera%2Fpipeline_handler.cpp%23n377&data=05%7C02%7Cjavier.carrasco%40wolfvision.net%7Cceed53d3ea3e474198f908dcf4d9f125%7Ce94ec9da9183471e83b351baa8eb804f%7C1%7C0%7C638654464149558114%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=7tKyOubPVOy6Avz3VQpA7lnUcU%2F%2FGSUWhqAOwYXBz80%3D&reserved=0<br>
> <br>
> So, we should the drop the ASSERT from rkisp1 pipeline handler and let<br>
> the base pipeline handler class handle the ASSERT (which it already does).<br>
> <br>
> It's redundant and called in wrong order currently. That should solve<br>
> the issue!<br>
> <br>
<br>
Hello Umang, thank you for your prompt reply.<br>
<br>
Our very first quick test was removing the ASSERT() to see what happens<br>
then, and we hit the second one you refer. They might be redundant, but<br>
removing one is not enough, at least in our case.<br>
<br>
The problem seems to be that a request stays in the pending state and it<br>
never changes. That does not happen every time we stop the camera by the<br>
way, only sporadically. That's why we think that it might be some<br>
sync-issue that could have something to do with the moment when stop()<br>
is triggered.<br>
<br>
When it actually happens, we can see that one request stays in the queue<br>
and it is never set to completed or cancelled. The rest of the requests<br>
are set to one of those states via tryCompleteRequest(), which in turn<br>
calls completeRequest().<br>
<br>
The completed/cancelled requests are popped out as soon as they reach<br>
the front of the queue, but eventually the pending request reaches the<br>
front, and the pipeline is never emptied:<br>
<br>
void PipelineHandler::completeRequest(Request *request)<br>
{<br>
Camera *camera = request->_d()->camera();<br>
<br>
request->_d()->complete();<br>
<br>
Camera::Private *data = camera->_d();<br>
<br>
while (!data->queuedRequests_.empty()) {<br>
Request *req = data->queuedRequests_.front();<br>
if (req->status() == Request::RequestPending)<br>
break;<br>
<br>
ASSERT(!req->hasPendingBuffers());<br>
data->queuedRequests_.pop_front();<br>
camera->requestComplete(req);<br>
}<br>
}<br>
<br>
which lead us to think that the completeRequest() call for that pending<br>
request was never being triggered, and we forced it to happen with the<br>
proposed patch in a similar fashion as in the patch we mentioned, maybe<br>
naively.<br>
<br>
</div></font>
</body>
</html>