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

Unhandled Exception: PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript ... ) #2

Closed
robin7331 opened this issue Apr 15, 2019 · 30 comments
Labels

Comments

@robin7331
Copy link

Hey there!

This package seemed to look pretty cool so I gave it a shot.
Unfortunately I get this error under iOS (haven't tested Android yet) when I hit the play button.

19:22:03.079 282 info flutter.tools [VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript, JavaScript string was: 'player.cueVideoById("secret-but-correct-video-id", 0)'

19:22:03.079 283 info flutter.tools 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})

I did run pod install and also flutter clean. The video thumbnail is showing up in my view so I guess thats at least a partial success.

@naval41
Copy link

naval41 commented Apr 16, 2019

I am facing same error :

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript, JavaScript string was: 'player.loadVideoById("iLnmTe5Q2Qw", 0)'
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})
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)

#2 WebViewController.evaluateJavascript (package:ytview/ytview.dart:590:22)

@sarbagyastha
Copy link
Owner

Thanks for reporting issue 😊 . The plugin is completely tested on Android only. Performing tests on iOS currently. Will push new version after tests complete, before this weekend.

@sarbagyastha sarbagyastha added the WIP Work In Progress label Apr 17, 2019
@jorg1piano
Copy link

Have the same issue, works great on android but on iOS I get the exception:

Unhandled Exception: PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript, JavaScript string was: 'player.playVideo()'
Error Domain=WKErrorDomain Code=2 "The Web Content process was terminated" UserInfo={NSLocalizedDescription=The Web Content process was terminated})

@janvandenberg
Copy link

janvandenberg commented Apr 20, 2019

+1 and thanks for creating this plugin @sarbagyastha

@sarbagyastha
Copy link
Owner

sarbagyastha commented Apr 21, 2019

Tested new Version 1.1.0 on iOS device and it works as intended, but in simulator video starts playing only after 4-5 minutes (although the above mentioned error shows up) in my case.
Can you guys check whether or not it is working on real iOS device as well as simulator.

@jorg1piano
Copy link

@sarbagyastha Still getting the same exception on iPhone 6s. Running 12.1.4

@dmazlum
Copy link

dmazlum commented Apr 21, 2019

Hello,

@sarbagyastha Still getting the same exception too on iPhone 8. Running 12.1.2

@janvandenberg
Copy link

Hi @sarbagyastha I've tested v1.1.0 on both a iOS 11 and 12 simulators (iPhone X, iPhone 8 etc) and a physical device (iPhone X) and it doesn't seem to be fixed.

I did manage to see a playing video on an iOS 11 simulator at one time, but only after 4-5 minutes like you described. When I restarted the simulator I got the error again:

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript, JavaScript string was: 'player.playVideo()'
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})

@sarbagyastha
Copy link
Owner

Done a little bit of debugging with Safari Web inspector, seems like the issue might be due to XHR ads related files. Will have to rewrite the iOS part i guess, so will take some time. If someone finds out workaround then a PR will be much appreciated. 😊

@pmrajani
Copy link

pmrajani commented Apr 25, 2019

Compiler message:
file:///C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/youtube_player_flutter-1.1.0/lib/src/youtube_player.dart:388:53: Error: The argument type 'Map<dynamic, dynamic>' can't be assigned to the parameter type 'Set'.

  • 'Map' is from 'dart:core'.
  • 'Set' is from 'dart:core'.
  • 'AudiovisualMediaTypes' is from 'package:ytview/ytview.dart' ('file:///C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/ytview-0.0.7+3/lib/ytview.dart').
    Try changing the type of the parameter, or casting the argument to 'Set'.
    mediaTypesRequiringUserActionForPlayback: {},
    ^
    Compiler failed on D:\AndroidStudioWorkspace\FlutterApps\my_smart_app\lib\main.dart
    *********************************************************
    WARNING: This version of image_picker will break your Android build if it or its dependencies aren't compatible with AndroidX.
    See https://goo.gl/CP92wY for more information on the problem and how to fix it.
    This warning prints for all Android build failures. The real root cause of the error may be unrelated.
    *********************************************************
    Finished with error: Gradle task assembleDebug failed with exit code 1

Can you check what is issue, i can't run app
i am using youtube_player_flutter: ^1.1.0 plugins

@sarbagyastha
Copy link
Owner

@pmrajani , can you report with flutter doctor -v output.

@pmrajani
Copy link

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v1.1.8, on Microsoft Windows [Version 10.0.17134.1], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.3)
[!] Connected device
! No devices available

! Doctor found issues in 1 category.

@sarbagyastha Here it is

@pmrajani
Copy link

[√] Flutter (Channel beta, v1.1.8, on Microsoft Windows [Version 10.0.17134.1], locale en-US)
• Flutter version 1.1.8 at C:\src\flutter
• Framework revision 985ccb6d14 (4 months ago), 2019-01-08 13:45:55 -0800
• Engine revision 7112b72cc2
• Dart version 2.1.1 (build 2.1.1-dev.0.1 ec86471ccc)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\Admin\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.

[√] Android Studio (version 3.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 33.4.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[!] Connected device
! No devices available

! Doctor found issues in 1 category.
@sarbagyastha

@sarbagyastha
Copy link
Owner

You're using older version of dart.. run flutter upgrade and the issue should be fixed.
Note: Set notation was only introduced in Dart 2.1.2 for Flutter.

@pmrajani
Copy link

@sarbagyastha it's works now thank you.

@dmazlum
Copy link

dmazlum commented Apr 29, 2019

Done a little bit of debugging with Safari Web inspector, seems like the issue might be due to XHR ads related files. Will have to rewrite the iOS part i guess, so will take some time. If someone finds out workaround then a PR will be much appreciated.

@sarbagyastha Hello how about that problem? I am waiting your upgrade.

@abeeriqbal
Copy link

Please fix Failed evaluating JavaScript, JavaScript string was: 'player.playVideo()' issue ASAP.

@sarbagyastha
Copy link
Owner

@dmazlum @abeeriqbal , currently having a tight schedule so will work on it as soon I get adequate time for it.

@abeeriqbal
Copy link

@dmazlum @abeeriqbal , currently having a tight schedule so will work on it as soon I get adequate time for it.

Any update?

@dmazlum
Copy link

dmazlum commented May 9, 2019

@abeeriqbal there is no update. I changed my player to webview. I embeded youtube code in webview. This is temporary solution. cheers

@sandyara
Copy link

sandyara commented May 9, 2019

Any Update ?

@silentsonata
Copy link

This bug is affecting me also. Love the plugin though!

@sarbagyastha
Copy link
Owner

Sorry folks, due to lack of spare time I couldn't work on the issue. I will work on it from next weekend onwards.

@sarbagyastha
Copy link
Owner

The issue is finally fixed and will be updating the plugin tonight. It's working on iOS now.
https://imgur.com/L19WXgK

@frgmt
Copy link

frgmt commented Oct 28, 2019

@sarbagyastha I had the same issue. In my case, when value.isReady is still false, I got an error. So, I modified to display the indicator and wait until isReady changes.
It might be better to show progress indicator until isReady changes true.

@sarbagyastha
Copy link
Owner

@frgmt Done in Version 6.0.0

@sarbagyastha sarbagyastha added fixed and removed WIP Work In Progress labels Nov 2, 2019
ynhi0711 pushed a commit to ynhi0711/youtube_player_flutter that referenced this issue Nov 10, 2022
…ncy_between_youtube_player_builder_and_youtube_player

Update dependency between YoutubePlayerBuilder and YoutubePlayer
@Kronos-2701
Copy link

" Unhandled Exception: PlatformException(FWFEvaluateJavaScriptError, Failed evaluating JavaScript., Instance of 'NSError', null) "

Facing this error while trying to run javascript on an iOS simulator.
@sarbagyastha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests