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

[src] Added manual binding to prevent issue of AVAudioPlayer FromData() and FromUrl() throwing exceptions. #17073

Merged

Conversation

dustin-wojciechowski
Copy link
Contributor

Was able to reproduce issue by creating a new Xamarin project and using an invalid NURL like in the issue. What happens is an exception is thrown by InitializeHandle (line 631 of NSObject2.cs) because the handle passed to it is null. I am unsure about this, but wonder if GetHandle's return of only an IntPtr instead of NativeHandle (in Selector.cs) is somehow causing an issue.

The desired behavior by user was to not have an exception thrown but to return null and assign the error to the out NSError parameter. The error code seems, on a quick Google search, with being unable to access a specified file.
"error {The operation couldn’t be completed. (OSStatus error 2003334207.)}"
Trivia: apparently that error code is a 4 character ASCII for "wht?"

I'm not sure if additional work needs to be done to the binding itself, since the user also indicated that this exception was thrown even with a valid NSURL.

I also adjusted the other methods in this class to have try/catch as well, in case this issue popped up again.

Fixes #16229

@dustin-wojciechowski dustin-wojciechowski changed the title Added try catches to the methods in AVAudioPlayer to prevent Initiali… [bug] Added try catches to the methods in AVAudioPlayer to prevent Initiali… Dec 15, 2022
@dustin-wojciechowski dustin-wojciechowski changed the title [bug] Added try catches to the methods in AVAudioPlayer to prevent Initiali… [src] Added try catches to the methods in AVAudioPlayer to prevent Initiali… Dec 15, 2022
@github-actions
Copy link
Contributor

⚠️ Your code has been reformatted. ⚠️

If this is not desired, add the actions-disable-autoformat label, and revert the reformatting commit.

If files unrelated to your change were modified, try reverting the reformatting commit + merging with the target branch (and push those changes).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Member

@rolfbjarne rolfbjarne left a comment

Choose a reason for hiding this comment

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

src/AVFoundation/AVAudioPlayer.cs Outdated Show resolved Hide resolved
src/AVFoundation/AVAudioPlayer.cs Outdated Show resolved Hide resolved
src/AVFoundation/AVAudioPlayer.cs Show resolved Hide resolved
src/AVFoundation/AVAudioPlayer.cs Show resolved Hide resolved
@dustin-wojciechowski
Copy link
Contributor Author

Tests are a little wonky for me locally because I'm having provisioning errors. So tests will probably need to be adjusted.

@github-actions
Copy link
Contributor

⚠️ Your code has been reformatted. ⚠️

If this is not desired, add the actions-disable-autoformat label, and revert the reformatting commit.

If files unrelated to your change were modified, try reverting the reformatting commit + merging with the target branch (and push those changes).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

src/AVFoundation/AVAudioPlayer.cs Outdated Show resolved Hide resolved
src/AVFoundation/AVAudioPlayer.cs Outdated Show resolved Hide resolved
src/AVFoundation/AVAudioPlayer.cs Outdated Show resolved Hide resolved
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@dustin-wojciechowski dustin-wojciechowski marked this pull request as ready for review December 21, 2022 20:14
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

Legacy Xamarin (No breaking changes)
  • iOS (no change detected)
  • tvOS (no change detected)
  • watchOS (no change detected)
  • macOS (no change detected)
NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

✅ API diff vs stable

Legacy Xamarin (No breaking changes)
.NET (No breaking changes)
Legacy Xamarin (stable) vs .NET

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 155a55661c408df18c4cc572ec64ddd7e687a0bb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [PR Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻

All tests on macOS M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Hash: 155a55661c408df18c4cc572ec64ddd7e687a0bb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

📚 [PR Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMBOT-1042.Monterey'
Hash: 155a55661c408df18c4cc572ec64ddd7e687a0bb [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build] Test results 🚀

Test results

✅ All tests passed on VSTS: simulator tests.

🎉 All 225 tests passed 🎉

Tests counts

✅ bcl: All 69 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ framework: All 8 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 7 tests passed. Html Report (VSDrops) Download
✅ install_source: All 1 tests passed. Html Report (VSDrops) Download
✅ introspection: All 8 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac_binding_project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch: All 25 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ mtouch: All 1 tests passed. Html Report (VSDrops) Download
✅ xammac: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 8 tests passed. Html Report (VSDrops) Download
✅ xtro: All 2 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 155a55661c408df18c4cc572ec64ddd7e687a0bb [PR build]

Copy link
Member

@rolfbjarne rolfbjarne left a comment

Choose a reason for hiding this comment

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

This looks great!

@dustin-wojciechowski dustin-wojciechowski changed the title [src] Added try catches to the methods in AVAudioPlayer to prevent Initiali… [src] Added manual binding to prevent issue of AVAudioPlayer FromData() and FromUrl() throwing exceptions. Jan 20, 2023
@dustin-wojciechowski dustin-wojciechowski merged commit 673cf36 into xamarin:main Jan 20, 2023
@dustin-wojciechowski dustin-wojciechowski deleted the avaudioplayer-fix branch January 20, 2023 18:05
rolfbjarne pushed a commit that referenced this pull request Jan 24, 2023
…() and FromUrl() throwing exceptions. (#17073)

Provided manual binding of AVAudioPlayer::initWithContentsOfURL:error: and AVAudioPlayer::initWithData:error: to prevent an issue where AVAudioPlayer::FromData() and FromUrl() do not throw exceptions when returning null.

Fixes #16229

Co-authored-by: GitHub Actions Autoformatter <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AVAudioPlayer.FromUrl crashes instead of returning error
3 participants