gh123man / SwiftUI-Refresher

A native, customizable SwiftUI refresh control
MIT License
119 stars 12 forks source link

fixed publishing ui changes on the main thread #6

Closed OrynaSemenets closed 1 year ago

gh123man commented 1 year ago

Hi @OrynaPanchenko Thanks for the PR.

Can you reproduce the issue this fixes? As far as I can tell introspect methods are always called on the main thread. The customize functions are called here which is called by the delegate method updateUIView that is always on the main actor.

Thanks!

PavelKoyushev commented 1 year ago

It's strange, there used to be a purple warning in the Refresher file on line 218, but now it's gone) But if it appears again, I'll send a screenshot)

12 мая 2023 г., в 17:54, Brian Floersch @.***> написал(а):

Hi @OrynaPanchenko https://github.com/OrynaPanchenko Thanks for the PR.

Can you reproduce the issue this fixes? As far as I can tell introspect methods are always called on the main thread. The customize functions are called here https://github.com/siteline/SwiftUI-Introspect/blob/master/Introspect/UIKitIntrospectionView.swift#L69 which is called by the delegate method updateUIView https://developer.apple.com/documentation/swiftui/uiviewrepresentable/updateuiview(_:context:) that is always on the main actor.

Thanks!

— Reply to this email directly, view it on GitHub https://github.com/gh123man/SwiftUI-Refresher/pull/6#issuecomment-1545871631, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEWXU5X6XX2DHVILWD6LJUDXFZFJRANCNFSM6AAAAAAVSJFLA4. You are receiving this because you are subscribed to this thread.

gh123man commented 1 year ago

Sounds good thanks!

rickpasetto commented 1 year ago

Chiming in here: I did see a runtime warning, not because it was not on the main thread, but because it was modifying state during a view update. For me it is 100% reproducible. Here's a screenshot. (Sorry to interrupt, I hope this helps, @gh123man, though...)

Screenshot 2023-05-31 at 8 46 37 AM

This patch does make the warning go away for me, for what it's worth.

gh123man commented 1 year ago

@rickpasetto Thanks for reporting this. ill take a look. I have seen the modifying state during a view update warnings and as I recall, these occur because of some dirty hacks to support iOS 14.

With iOS 14 being largely unused these days, I'm going to drop support soon and hopefully resolve all of these issues in the process. Ill keep this thread updated.

Thanks!

gh123man commented 1 year ago

Can anyone repro modifying state during a view update or action tried to update multiple times per frame on iOS 16.2+?

I was playing with the simulators and this only appears on iOS 15. Seems fixed on iOS 16+. If this is the case, it may be best to leave it as is.

Other than the annoying Xcode warning, I don't think this has any tangible behavior impact.

Econa77 commented 1 year ago

@gh123man I have reproduced this issue too. ( iOS16.4 / Simulator )

スクリーンショット 2023-07-12 13 46 18

The warning will no longer be output with this PR change.

piggy-park commented 1 year ago

I have reproduced this issue too (16.4 / 14 Pro / Simulator)

gh123man commented 1 year ago

Thanks for the feedback and the PR.