tvOSBrowser icon indicating copy to clipboard operation
tvOSBrowser copied to clipboard

Fix a crash for "WebCoreNSURLSessionTaskTransactionMetrics _privacyStance]: unrecognized selector sent to instance"

Open staskus opened this issue 2 years ago • 9 comments

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!

staskus avatar Jan 18 '23 19:01 staskus

Hi staskus, can you teach me where and how to add the dummy? I am only a beginner of the coding

alferd4829 avatar Oct 01 '23 07:10 alferd4829

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.

staskus avatar Oct 02 '23 06:10 staskus

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? TVOS

alferd4829 avatar Oct 02 '23 07:10 alferd4829

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.

staskus avatar Oct 02 '23 07:10 staskus

Thank you for your quick reply.

Which file that I need to choose for? Supported File

alferd4829 avatar Oct 02 '23 07:10 alferd4829

Which file that I need to choose for?

.m file. I found .h file not required in this case.

staskus avatar Oct 02 '23 10:10 staskus

Thank you. It works now. Do you had any solution to make the video played in full screen mode?

alferd4829 avatar Oct 02 '23 13:10 alferd4829

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.

staskus avatar Oct 02 '23 14:10 staskus

Understood. Hope you can found out the solution in one day

alferd4829 avatar Oct 03 '23 02:10 alferd4829