I know that activity diagrams are difficult. But this comes out quite ridiculous:
@startuml receive-loop.svg
' ========== Receive loop =========
skinparam conditionStyle diamond
title Receive Loop
start
while ( ) is ([connection open])
:Receive data;
while ( ) is ([data in receive buffer])
:Invoke decode;
:Handle decoder result;
endwhile ([else])
endwhile ([else])
end
@enduml
The problem with the outer loop is the placement of the "end". When an "end" or "stop" is used after "if" or "else", it is put next to the decision point. Whatever comes after the "endwhile" is actually equivalent to what comes after the "else" (of an "if"). So the placement of a "stop" or "end" after "endwhile" should be handled in a similar way.
The problem with the inner loop is the "snake" formed by the "else" transition. This could be avoided if there was some means to change the direction of the "[else]" transition that goes out of the decision point. It could e.g. be allowed to use "-right->" (in this case after the inner "endwhile") as in class diagrams.