From: Wang, Jerry
Sent: Friday, 19 June, 2015 4:31 PM
Subject: RE: [Follow up] Why the synchronous request did not BLOCK the UI
Hi all,
這個issue很有意思,昨天和德國同僚開會時,他們問我們為什麼我們code裡寫的odata request是同步的,但是并沒有block 住UI。當時我沒答上來,因為确實我看起來也是沒block UI。
今天我做了研究,通過圖表和視訊 理直氣壯地告訴他們:代碼沒問題,是我們眼睛犯錯了。視訊在下面的share folder裡。研究思路在下面的郵件裡。
Please read more detail from Jerry’s mail.
Jerry’s analysis process
手動在背景reques響應裡加上一個延時,來模拟背景耗時很長的scenario.
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5iM5M2YlJjZjljM0IGZ2kTO1MDO0YGMwUjZ2UDOlRGM08CX5d2bs92Yl1iclB3bsVmdlR2LcNWaw9CXt92Yu4GZjlGbh5yYjV3Lc9CX6MHc0RHaiojIsJye.png)
Then I test in UI with this modified Odata implementation. Now as expected it took around 13 seconds to get the returned image url.
During this timeframe, UI is completely freezed: end user does not have any chances to click anything in UI.
Synchronous mode
Afterwards the synchronous behavior is quite obvious now. I click one item in navigation list to trigger the synchronous request for Image url retrieval. And after that, I cannot do any operation on UI - it is completely freezed.