Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error occurred when set perspective360Degree for 360 video. #69

Closed
ewangke opened this issue Jul 3, 2023 · 4 comments
Closed

Error occurred when set perspective360Degree for 360 video. #69

ewangke opened this issue Jul 3, 2023 · 4 comments
Assignees
Labels
youtube-player-iframe-api-bug Something isn't working in the context of the YouTube Player iFrame API

Comments

@ewangke
Copy link

ewangke commented Jul 3, 2023

What happened?

Hi, @SvenTiigi

I'm trying to YouTube play 360 video with the cool project, but an error occurred when set perspective360Degree. I set a breakpoint on YouTubePlayerWebView+Evaluate.swift:81, and the error message is as below:

(lldb) po error
▿ Optional<Error>
  - some : Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type}

The javascript executed is as below:

(lldb) po javaScript
▿ JavaScript
  - rawValue : "player.setSphericalProperties({\"yaw\":50,\"fov\":30,\"pitch\":20,\"roll\":60});"

which is generated by API call like this:

self.youTubePlayer.set(
   perspective360Degree: .init(
        yaw: 50,
        pitch: 20,
        roll: 60,
        fov: 10
   )
)

What are the steps to reproduce?

Step 1:

Replace the button event with code snippets below

self.youTubePlayer.set(
   perspective360Degree: .init(
        yaw: 50,
        pitch: 20,
        roll: 60,
        fov: 10
   )
)

Replace the WWDC22 url with another 360 YouTube url: https://www.youtube.com/watch?v=s_hdc_XiXiA&t=4s

Step 2:

Build and run the Example target,I tried both the simulator and iPhone device. Tap any item within the scrollView to trigger perspective360Degree update.

What is the expected behavior?

I tried to update perspective360Degree and expect different perspective can be viewed, just like the official iframe - Controlling 360° videos demo.

Would you please look into this issue, or maybe give me some hint for debugging. Many thanks!

@ewangke ewangke added the bug Something isn't working label Jul 3, 2023
SvenTiigi added a commit that referenced this issue Jul 3, 2023
@SvenTiigi
Copy link
Owner

Thanks for your excellent bug report @ewangke.

Since the JavaScript execution returned a result of an unsupported type WKError comes directly from the evaluateJavaScript function of WKWebView, it seems that the setSphericalProperties JavaScript function returns an invalid value that isn't supported by WebKit/WKWebView, such as null.

I've added a fix to the develop branch which wraps the execution of the JavaScript function in a self-executing anonymous JavaScript function to avoid the invalid return value.

@SvenTiigi SvenTiigi added youtube-player-iframe-api-bug Something isn't working in the context of the YouTube Player iFrame API and removed bug Something isn't working labels Jul 3, 2023
@ewangke
Copy link
Author

ewangke commented Jul 4, 2023

Thanks for your fix and quick response @SvenTiigi .

The fix eliminates the WKError now.

But I still can't update video's perspective by API setSphericalProperties, and getSphericalProperties always returns an empty object.

I notice that the official document example works on Safari for macOS, but didn't work on mobile Safari for iOS.

I know that it's most likely the iFrame API limitation. Is it possible to play 360 video via iFrame API on iOS?

@SvenTiigi
Copy link
Owner

Hi @ewangke,

I've tested the video perspective APIs and can confirm that the setSphericalProperties and getSphericalProperties JS functions of the YouTube Player iFrame API are definitely not working correctly on iOS and macOS 🙈

As a result I will remove the video perspective APIs from YouTubePlayerKit as there is no suitable workaround available and the official youtube-ios-player-helper also doesn't provide any kind of support for this API.

Thanks for your investigations!

SvenTiigi added a commit that referenced this issue Jul 4, 2023
@ewangke
Copy link
Author

ewangke commented Jul 5, 2023

@SvenTiigi, thanks for your help!

@ewangke ewangke closed this as completed Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
youtube-player-iframe-api-bug Something isn't working in the context of the YouTube Player iFrame API
Projects
None yet
Development

No branches or pull requests

2 participants