[Regression]: Fix the timeout issue when reading pipe reply packets for committing cloud candidates and newly created words.
This commit is contained in:
1 parent
d7c6686f6f
commit
b25281ff46
4 files changed
+36
-17
No files matched your search
+1
-3
@@ -652,7 +652,7 @@ void ClearNamedpipeDataIfExists(bool force)
|
||||
struct FanyImeNamedpipeDataToTsf *TryReadDataFromServerPipeWithTimeout()
|
||||
{
|
||||
std::pair<UINT, std::wstring> ret = {0, L""};
|
||||
int timeoutMs = 10; // Default timeout 10ms
|
||||
int timeoutMs = 50; // Default timeout 50ms
|
||||
|
||||
if (!hFromServerPipe || hFromServerPipe == INVALID_HANDLE_VALUE) // Try to reconnect
|
||||
{
|
||||
@@ -707,8 +707,6 @@ struct FanyImeNamedpipeDataToTsf *TryReadDataFromServerPipeWithTimeout()
|
||||
}
|
||||
}
|
||||
|
||||
FANY_IPC_LOGF(L"[msime]: [ipc] TryReadDataFromServerPipeWithTimeout timeout after {} ms", timeoutMs);
|
||||
|
||||
namedpipeDataFromServer.msg_type = Global::DataFromServerMsgType::Normal;
|
||||
// Pipe timeout error
|
||||
wcscpy_s(namedpipeDataFromServer.candidate_string, L"T");
|
||||
|
||||
@@ -414,10 +414,6 @@ STDAPI CMetasequoiaIME::OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lP
|
||||
|
||||
if (code == VK_SPACE && KeystrokeState.Function == FUNCTION_CONVERT)
|
||||
{
|
||||
PerfTimer prefetchTimer;
|
||||
FanyImeNamedpipeDataToTsf *receivedData = TryReadDataFromServerPipeWithTimeout();
|
||||
_QueuePendingServerCandidate(receivedData->msg_type, receivedData->candidate_string);
|
||||
|
||||
if (_msgWndHandle)
|
||||
{
|
||||
PostMessage(_msgWndHandle, WM_AsyncFinalizeCandidate, 0, 0);
|
||||
@@ -430,18 +426,13 @@ STDAPI CMetasequoiaIME::OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lP
|
||||
std::wstring punctuationCommitText;
|
||||
const WCHAR *punctuation = _pCompositionProcessorEngine->GetPunctuation(wch);
|
||||
punctuationCommitText = punctuation ? punctuation : L"";
|
||||
|
||||
double prefetchElapsedMs = 0;
|
||||
if (_candidateMode != CANDIDATE_NONE && _pCandidateListUIPresenter &&
|
||||
Global::CommitWithFirstCandPunc.count(wch) > 0)
|
||||
const bool shouldFinalizeFirstCandidateWithPunctuation =
|
||||
_candidateMode != CANDIDATE_NONE && _pCandidateListUIPresenter &&
|
||||
Global::CommitWithFirstCandPunc.count(wch) > 0;
|
||||
if (!shouldFinalizeFirstCandidateWithPunctuation)
|
||||
{
|
||||
PerfTimer prefetchTimer;
|
||||
FanyImeNamedpipeDataToTsf *receivedData = TryReadDataFromServerPipeWithTimeout();
|
||||
prefetchElapsedMs = prefetchTimer.ElapsedMs();
|
||||
punctuationCommitText = std::wstring(receivedData->candidate_string) + punctuationCommitText;
|
||||
_QueuePendingPunctuationCommitText(punctuationCommitText.c_str());
|
||||
}
|
||||
|
||||
_QueuePendingPunctuationCommitText(punctuationCommitText.c_str());
|
||||
PostMessage(_msgWndHandle, WM_AsyncPunctuationCommit, 0, 0);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
namespace
|
||||
{
|
||||
std::wstring g_toggleImeFallbackBuffer;
|
||||
|
||||
bool IsTimeoutSentinelCandidate(UINT msgType, const WCHAR *pCandidateString)
|
||||
{
|
||||
return msgType == Global::DataFromServerMsgType::Normal && pCandidateString != nullptr &&
|
||||
wcscmp(pCandidateString, L"T") == 0;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -801,6 +807,10 @@ HRESULT CMetasequoiaIME::_HandleCompositionPunctuation(TfEditCookie ec, _In_ ITf
|
||||
PerfTimer pipeReadTimer;
|
||||
struct FanyImeNamedpipeDataToTsf *receivedData = TryReadDataFromServerPipeWithTimeout();
|
||||
pipeReadElapsedMs = pipeReadTimer.ElapsedMs();
|
||||
if (IsTimeoutSentinelCandidate(receivedData->msg_type, receivedData->candidate_string))
|
||||
{
|
||||
receivedData = TryReadDataFromServerPipeWithTimeout();
|
||||
}
|
||||
punctuationStr = std::wstring(receivedData->candidate_string) + punctuationStr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,14 @@ const int MOVEDOWN_ONE = 1;
|
||||
const int MOVETO_TOP = 0;
|
||||
const int MOVETO_BOTTOM = -1;
|
||||
|
||||
namespace
|
||||
{
|
||||
bool IsTimeoutSentinelCandidate(UINT msgType, const std::wstring &candidateString)
|
||||
{
|
||||
return msgType == Global::DataFromServerMsgType::Normal && candidateString == L"T";
|
||||
}
|
||||
}
|
||||
|
||||
//+---------------------------------------------------------------------------
|
||||
//
|
||||
// _HandleCandidateFinalize
|
||||
@@ -82,6 +90,12 @@ HRESULT CMetasequoiaIME::_HandleCandidateFinalize(TfEditCookie ec, _In_ ITfConte
|
||||
_TakePendingServerCandidate(&serverMsgType, &serverCandidateString);
|
||||
if (hasPrefetchedServerCandidate)
|
||||
{
|
||||
if (IsTimeoutSentinelCandidate(serverMsgType, serverCandidateString))
|
||||
{
|
||||
struct FanyImeNamedpipeDataToTsf *retryData = TryReadDataFromServerPipeWithTimeout();
|
||||
serverMsgType = retryData->msg_type;
|
||||
serverCandidateString = retryData->candidate_string;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -89,6 +103,12 @@ HRESULT CMetasequoiaIME::_HandleCandidateFinalize(TfEditCookie ec, _In_ ITfConte
|
||||
struct FanyImeNamedpipeDataToTsf *receivedData = TryReadDataFromServerPipeWithTimeout();
|
||||
serverMsgType = receivedData->msg_type;
|
||||
serverCandidateString = receivedData->candidate_string;
|
||||
if (IsTimeoutSentinelCandidate(serverMsgType, serverCandidateString))
|
||||
{
|
||||
struct FanyImeNamedpipeDataToTsf *retryData = TryReadDataFromServerPipeWithTimeout();
|
||||
serverMsgType = retryData->msg_type;
|
||||
serverCandidateString = retryData->candidate_string;
|
||||
}
|
||||
}
|
||||
|
||||
if (serverMsgType == Global::DataFromServerMsgType::OutofRange) // Candidate index out of range
|
||||
|
||||
Reference in new issue
Block a user