Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[video_player] added iOS exception on incorrect asset path #4318

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

Merged

Conversation

zopagaduanjr
Copy link
Contributor

surfaced the incorrect asset path error to dart using try catch.

Fixes #118660

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some description with the exception logs before and after your change.

playerFactory:_playerFactory];
return [self onPlayerSetup:player frameUpdater:frameUpdater];
}
@catch (NSException *exception) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did it crash before when the exception is thrown?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for ios yes. using the code sample of flutter/flutter#118660 (comment), it should crash and look like this

Screenshot 2023-06-28 at 9 47 56 PM

@zopagaduanjr zopagaduanjr force-pushed the video_player/ios-asset-exception branch from 69fef98 to 330b347 Compare June 28, 2023 13:32
@zopagaduanjr
Copy link
Contributor Author

current exception logs when asset path is incorrect

Lost connection to device.
Exception: Unable to terminate com.example.delete on 3665098C-8CA5-41DD-9915-520BC16A4457:
ProcessException: Process exited abnormally:
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=3):
Simulator device returned an error for the requested operation.
found nothing to terminate
Underlying error (domain=NSPOSIXErrorDomain, code=3):
	The operation couldn’t be completed. found nothing to terminate
	found nothing to terminate
  Command: /usr/bin/arch -arm64e xcrun simctl terminate 3665098C-8CA5-41DD-9915-520BC16A4457 com.example.delete
Failed to send request: {"jsonrpc":"2.0","id":"21","method":"getObject","params":{"isolateId":"isolates/842831092504847","objectId":"libraries/@609171358"}}

@zopagaduanjr
Copy link
Contributor Author

the proposed try catch update will now raise a platformException, and will not instantly crash the app

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(video_player, *** -[NSURL initFileURLWithPath:]: nil string parameter, null, null)
#0      AVFoundationVideoPlayerApi.create (package:video_player_avfoundation/src/messages.g.dart:298:7)
<asynchronous suspension>
#1      AVFoundationVideoPlayer.create (package:video_player_avfoundation/src/avfoundation_video_player.dart:65:37)
<asynchronous suspension>
#2      VideoPlayerController.initialize (package:video_player/video_player.dart:404:19)
<asynchronous suspension>

Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a good change. can you add some tests?

@zopagaduanjr zopagaduanjr force-pushed the video_player/ios-asset-exception branch from 997fa36 to 2d1162b Compare June 29, 2023 05:56
@zopagaduanjr zopagaduanjr force-pushed the video_player/ios-asset-exception branch from 2d1162b to ebcf0e3 Compare July 1, 2023 00:39
try {
await player.create(DataSource(
sourceType: DataSourceType.asset,
asset: 'incorrectAsset',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you make it look more like a path, e.g. /path/to/incorrect_asset

@zopagaduanjr zopagaduanjr force-pushed the video_player/ios-asset-exception branch 2 times, most recently from 2a306b5 to 4ecf1df Compare July 6, 2023 04:19
Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to run the format command dart pub global run flutter_plugin_tools format --packages video_player before this can land.

@zopagaduanjr zopagaduanjr force-pushed the video_player/ios-asset-exception branch from 4ecf1df to e632d70 Compare July 11, 2023 12:27
@zopagaduanjr
Copy link
Contributor Author

finished running the format command

@zopagaduanjr zopagaduanjr force-pushed the video_player/ios-asset-exception branch from 9420170 to 7840012 Compare July 12, 2023 08:46
Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with one small change.

@zopagaduanjr zopagaduanjr force-pushed the video_player/ios-asset-exception branch from 7840012 to 9e77817 Compare July 13, 2023 01:39
@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 14, 2023
@auto-submit auto-submit bot merged commit 4c11497 into flutter:main Jul 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 14, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jul 14, 2023
flutter/packages@aa1eace...369ee7e

2023-07-14 [email protected] [Tool] New tool to download android dependencies  (flutter/packages#4408)
2023-07-14 [email protected] [video_player] added iOS exception on incorrect asset path (flutter/packages#4318)
2023-07-14 [email protected] [google_maps_flutter_platform_interface] Add support for cloud-based map styling (flutter/packages#4141)
2023-07-14 [email protected] [webview_flutter] Adds support for receiving a url with WebResourceError (flutter/packages#3884)
2023-07-14 [email protected] [xdg_directories] Remove `process` dependency (flutter/packages#4460)
2023-07-13 [email protected] [various] Update Pigeon in Swift plugins (flutter/packages#4461)
2023-07-13 [email protected] Roll Flutter from 544d30d to c40173f (10 revisions) (flutter/packages#4457)
2023-07-13 [email protected] Roll Flutter (stable) from 796c8ef to f468f33 (2 revisions) (flutter/packages#4456)
2023-07-13 [email protected] Fix Router Config Issues #4300 (go_router_builder/example)  (flutter/packages#4369)
2023-07-13 [email protected] [webview_flutter_platform_interface] Adds url to `WebResourceError` (flutter/packages#4439)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Jul 31, 2023
flutter/packages@aa1eace...369ee7e

2023-07-14 [email protected] [Tool] New tool to download android dependencies  (flutter/packages#4408)
2023-07-14 [email protected] [video_player] added iOS exception on incorrect asset path (flutter/packages#4318)
2023-07-14 [email protected] [google_maps_flutter_platform_interface] Add support for cloud-based map styling (flutter/packages#4141)
2023-07-14 [email protected] [webview_flutter] Adds support for receiving a url with WebResourceError (flutter/packages#3884)
2023-07-14 [email protected] [xdg_directories] Remove `process` dependency (flutter/packages#4460)
2023-07-13 [email protected] [various] Update Pigeon in Swift plugins (flutter/packages#4461)
2023-07-13 [email protected] Roll Flutter from 544d30d to c40173f (10 revisions) (flutter/packages#4457)
2023-07-13 [email protected] Roll Flutter (stable) from 796c8ef to f468f33 (2 revisions) (flutter/packages#4456)
2023-07-13 [email protected] Fix Router Config Issues flutter#4300 (go_router_builder/example)  (flutter/packages#4369)
2023-07-13 [email protected] [webview_flutter_platform_interface] Adds url to `WebResourceError` (flutter/packages#4439)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App needs tests p: video_player platform-ios
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[video_player] IOS app crashes without any error when the assets path is incorrect
3 participants