AI Briefing
KO

Kakao FE Analyzes Lack of Promise Cancellation and Shares Solution for Ad SDK Rendering Cancellation

·2023.01.11 00:00

Key point

Kakao FE analyzed the reasons behind the stalled standardization of Promise cancellation and shared a case study on resolving rendering cancellation issues in ad SDKs using a rollback delay approach.

1 / 4

Details

Kakao Biz FE team analyzed the lack of Promise cancellation functionality encountered during ad SDK development and its background. While Promise treats asynchronous states as values, TC39 has discussed standardizing a general cancellation feature for a long time but failed to reach an agreement. The initially proposed Cancel Token had the advantage of separating Promise and cancellation functionality, but language-level standardization was halted after WHATWG's AbortController and AbortSignal were adopted as Web API standards first.

Difficulties in Standardizing Promise Cancellation

There are three main reasons why standardizing cancellation is difficult. First, there is no consensus on whether to treat cancellation as a general exception or handle it with separate syntax. Handling it as an exception, like in C#, generates unnecessary error logs, while introducing separate syntax complicates the specification. Second, the expected behavior of cancellation is ambiguous. It is difficult to define whether it should be seen as an error occurrence or as maintaining the Pending state. Third, there are compatibility issues with existing code. Adding cancellation functionality to Promise could unintentionally affect existing logic, such as cache implementations. Additionally, AbortController is dependent on Web platform features like EventTarget, which limits its adoption as an ECMAScript standard.

Resolving Rendering Cancellation in Ad SDKs

In the ad SDK, there was an issue where memory leaks occurred because rollback functions were not saved when ads were removed during rendering. Attempts to directly implement Promise cancellation failed because checking for cancellation midway through asynchronous code caused unpredictable side effects. Instead of immediately stopping rendering, the issue was resolved by saving the removal to a buffer when the ad was removed and performing a rollback after rendering was complete. This method is simple to implement and, thanks to fast rendering speeds, does not significantly impact user experience.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.