Fix a crash for "WebCoreNSURLSessionTaskTransactionMetrics _privacyStance]: unrecognized selector sent to instance"
Fixes: #54
Due to issues with WebKit and tvOS, [WebCoreNSURLSessionTaskTransactionMetrics _privacyStance]: unrecognized selector sent to instance crash anytime the video is played.
Solution
Add a dummy _privacyStance getter at runtime which returns 0. The system expects a value from nw_connection_privacy_stance_t enum where 0 means nw_connection_privacy_stance_unknown.
Let me know if you have any questions, thanks!
Hi staskus, can you teach me where and how to add the dummy? I am only a beginner of the coding
Hey, @alferd4829. Sure.
I am only a beginner of the coding
Don't worry, the workaround I'm proposing here is usually not what is needed when coding apps.
can you teach me where and how to add the dummy?
Here are the changes of the pull request: https://github.com/jvanakker/tvOSBrowser/pull/58/files
It's enough to add WebCoreNSURLSessionTaskTransactionMetrics+AddPrivacyStance.m file to the project next to other classes to the workaround would work. Objective-C allows overriding methods even in the category (extension). Here I am overriding the load method of WebCoreNSURLSessionTaskTransactionMetrics class, and using some more Objective-C runtime magic to add privacyStance method to the class, which the system expects to exist.
Thank you for your reply.
I try to add the File inside Browser folder and choose Objective-C file as the file template. Next what should I choose for this file type?
I try to add the File inside Browser folder and choose Objective-C file as the file template. Next what should I choose for this file type?
This file is Category.
However, in this instance you can choose anything, File Type choice determines a boilerplate for the file. However, you will just copy-paste changes from this pull request.
Thank you for your quick reply.
Which file that I need to choose for?
Which file that I need to choose for?
.m file. I found .h file not required in this case.
Thank you. It works now. Do you had any solution to make the video played in full screen mode?
Thank you. It works now. Do you had any solution to make the video played in full screen mode?
Unfortunately, no. I haven't really looked into that.
Understood. Hope you can found out the solution in one day