I found a problem when using WebAuthenticationSession in a project that uses TCA framework
Problem:
A non-main thread issue occurs when closing the WebAuthenticationSession window.
(Warnings generated by the TCA library)
(Warnings generated by the SwiftUI Framework)
Cause:
The problem does not occur when using the pure SwiftUI @Binding. However, when assigning a Binding variable to isPresented: using TCA, it appears that the action of the Binding variable becoming false when the window closes is executed in the background. (This is just a guess of mine, so it may be wrong.)
Anyway, the problem occurs when the value of the variable item is changeed to nil inside the completionHandler of the WebAuthenticationPresenter.
Solution:
This commit is modified to run on the main thread in the resetItemBinding() function.
Hello ๐
I found a problem when using
WebAuthenticationSession
in a project that uses TCA frameworkProblem:
A non-main thread issue occurs when closing the
WebAuthenticationSession
window.(Warnings generated by the TCA library)
(Warnings generated by the SwiftUI Framework)
Cause:
The problem does not occur when using the pure SwiftUI
@Binding
. However, when assigning a Binding variable toisPresented:
usingTCA
, it appears that the action of the Binding variable becoming false when the window closes is executed in the background. (This is just a guess of mine, so it may be wrong.)Anyway, the problem occurs when the value of the variable
item
is changeed tonil
inside thecompletionHandler
of theWebAuthenticationPresenter
.Solution:
This commit is modified to run on the main thread in the
resetItemBinding()
function.Testing:
I confirmed that this modification does not cause side effects when using pure SwiftUI.
Request:
Please let me know if there is a possibility that another problem may occur due to this modification. If not, please reflect it in the main branch.
Thank you for your time. Have a nice day.
์๋ ํ์ธ์. ์์ด๋ก ๋ฒ์ญํ๋ ๊ณผ์ ์์ ์๋๊ฐ ์ ํํ ์ ๋ฌ๋์ง ์์ ๋ถ๋ถ์ด ์์ ๊ฒ ๊ฐ์, ํ๊ตญ์ด๋ก ์์ฝํ ๋ด์ฉ๋ ํจ๊ป ๊ธฐ์ฌํฉ๋๋ค.
TCA๋ฅผ ์ฌ์ฉํ๋ ํ๋ก์ ํธ์์
WebAuthenticationSession
์ ์ฌ์ฉํ ๋, ๋ค์๊ณผ ๊ฐ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ ๊ฒ์ ์๊ฒ ๋์์ต๋๋ค.๋ฌธ์ :
WebAuthenticationSession
์ฐฝ์ด ๋ซํ ๋, non-main thread ๊ด๋ จ ๋ฌธ์ ๋ฐ์. (์ด๋ฏธ์ง ์๋ต)์์ธ ํ์ :
์์ํ SwiftUI์
@Binding
์ ์ด์ฉํ์์ ๋๋ ๋ฌธ์ ๊ฐ ์์์ต๋๋ค. ํ์ง๋ง TCA๋ฅผ ์ฌ์ฉํ์ฌisPresented:
์ Binding ๋ณ์๋ฅผ ํ ๋นํ๊ฒ ๋๋ฉด ์ฐฝ์ด ๋ซํ๋ฉด์ Binding ๋ณ์๊ฐ false๋ก ๋ณํ๋ ๋์์ด background์์ ์คํ์ด ๋๋ ๊ฒ์ผ๋ก ๋ณด์ ๋๋ค. (์ถ์ธก์ด๋ฏ๋ก, ํ๋ ธ์ ์๋ ์์.)์ด์จ๋ , ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ ์์ ์
WebAuthenticationPresenter
์completionHandler
์ ๋์ ๋ด๋ถ์์ ๋ณ์item
์ ๊ฐ์nil
๋ก ์ด๊ธฐํ ํ ๋์ธ ๊ฒ์ผ๋ก ํ์ธํ์ต๋๋ค.ํด๊ฒฐ ๋ฐฉ์ ์ ์ :
resetItemBinding()
ํจ์ ๋ด๋ถ์ ์ฝ๋๋ฅผ main thread์์ ๋์ํ๋๋ก ์์ .์ด ์์ ์ ์์ํ๊ฒ SwiftUI๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์ ๋ํด side effect๋ฅผ ๋ฐ์์ํค์ง ์๋๊ฒ์ผ๋ก ํ์ธํ์ต๋๋ค. ๋ง์ฝ ์ด ์์ ์ผ๋ก ์ธํด ์ ๊ฐ ๋ชจ๋ฅด๋ ๋ ๋ค๋ฅธ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ๊ฐ๋ฅ์ฑ์ด ์๋ค๋ฉด ์๋ ค์ฃผ์๊ณ , ๊ทธ๋ ์ง ์๋ค๋ฉด main branch์ ๋ฐ์์์ผ์ฃผ์๊ธฐ๋ฅผ ๋ถํ๋๋ฆฝ๋๋ค.
๊ณ ๋ง์ต๋๋ค. ์ข์ ํ๋ฃจ ๋ณด๋ด์ธ์.