Cocoanetics / DTCoreText

Methods to allow using HTML code with CoreText
BSD 2-Clause "Simplified" License
6.35k stars 1.18k forks source link

On iOS 16, enabling VoiceOver and rendering custom views using DTAttributedTextContentView causes crashes. #1272

Closed duxinfeng closed 1 year ago

duxinfeng commented 1 year ago

On iOS 15 and 14, setting  view.isAccessibilityElement = NO; can resolve the issue. However, on iOS 16 crashes still occur.

When I tried running the DTCoreText Demo, using VoiceOver and tapping on the first READE ME example also caused crashes.

WX20230627-150541@2x

VitoByChen commented 1 year ago

Same case whit me on my project, Hopefully it will be fixed soon, there are a lot of crashes online

odrobnik commented 1 year ago

I found that this comes from iOS seemingly having a problem with NSProxy. That's being used to have a stand-in for a custom text attachment view that might be not created yet. It can also be worked around by omitting such a proxy for all text attachments.

Anybody have a custom view that implements accessibility?

So for the time being - until we know better - I've just replaced the NSProxy with NSObject. With that the crash doesn't occur.

duxinfeng commented 1 year ago

Thank you for your answer. Replacing NSObject with NSProxy solved the problem of my project crashing

duxinfeng commented 1 year ago

I'm very sorry, after replacing NSProxy with NSObject, Custom Objects will crash. In the DTCoreText demo, Custom Objects has this problem.

IMG_2045

odrobnik commented 1 year ago

In that case we'll have to change the logic for voice over for custom objects. Instead of having a proxy forwarding calls, we'll have to return the custom views themselves.

duxinfeng commented 1 year ago

In that case we'll have to change the logic for voice over for custom objects. Instead of having a proxy forwarding calls, we'll have to return the custom views themselves.

Thank you for your answer. I have removed the DTAttributedTextContentView Accessibility related event and resolved my issue first.

yanjincheng commented 1 year ago

Isn't that what custom views can't use?