Skip to content

VTDecompressionSession.DecodeFrame and NewDecompressionCallback #17394

@BlackTr

Description

@BlackTr

When calling a VTDecompressionSession.DecodeFrame in Visual Studio for Mac 17.4.3 with wrong buffer data for decoder, the Callback not called and application crashed.

Steps to Reproduce

// callback
private void OutputCallback(IntPtr sourceFrame,
    VTStatus status,
    VTDecodeInfoFlags vtDecodeInfoFlags,
    CVImageBuffer buffer,
    CMTime presentationTimestamp,
    CMTime presentationDuration)
{
}

// create session
_decSession = VTDecompressionSession.Create(OutputCallback,
            _formatDescription,
            videoDecoderSpecification,
            destinationImageBufferAttributes);

// decode frame
var decodeStatus = _decSession.DecodeFrame(sampleBuffer, VTDecodeFrameFlags.EnableAsynchronousDecompression, IntPtr.Zero, out VTDecodeInfoFlags infoFlags);

Expected Behavior

The Callback is called and provide null in CVImageBuffer buffer and provide error in VTStatus status if possible

Actual Behavior

The Callback not called and application crashed with exception:

Maui[20537:2930599] *** Terminating app due to uncaught exception 'System.Exception', reason: 'Could not initialize an instance of the type 'CoreVideo.CVPixelBuffer': handle is null.
It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false. (System.Exception)
   at ObjCRuntime.DisposableObject.InitializeHandle(NativeHandle handle, Boolean verify)
   at ObjCRuntime.DisposableObject..ctor(NativeHandle handle, Boolean owns, Boolean verify)
   at CoreFoundation.NativeObject..ctor(NativeHandle handle, Boolean owns, Boolean verify)
   at CoreVideo.CVBuffer..ctor(NativeHandle handle, Boolean owns)
   at CoreVideo.CVImageBuffer..ctor(NativeHandle handle, Boolean owns)
   at CoreVideo.CVPixelBuffer..ctor(NativeHandle handle, Boolean owns)
   at VideoToolbox.VTDecompressionSession.NewDecompressionCallback(IntPtr outputCallbackClosure, IntPtr sourceFrame, VTStatus status, VTDecodeInfoFlags infoFlags, IntPtr imageBufferPtr, CMTime presentationTimeStamp, CMTime presentationDuration)
'

Environment

Version information
Visual Studio Enterprise 2022 for Mac
Version 17.4.3 (build 21)
Installation UUID: 5c1fe431-71a3-473a-9c74-2dc970827e97

Runtime
.NET 6.0.12 (64-bit)
Architecture: X64

Roslyn (Language Service)
4.4.0-6.22578.12+3c6ab8e1715e5b080fb7bb77070810ab71e09387

NuGet
Version: 6.3.1.1

.NET SDK (x64)
SDK: /usr/local/share/dotnet/sdk/7.0.102/Sdks
SDK Versions:
	7.0.102
	7.0.101
	7.0.100
	6.0.405
	6.0.404
	6.0.403
	6.0.402
	6.0.401
	6.0.201
	6.0.100
	3.1.426
	3.1.425
	3.1.424
	3.1.423
	3.1.417
	3.1.401
	2.2.103
	2.1.302
	2.1.4
	2.0.0
	2.0.0-preview2-006127
	1.0.4
	1.0.1
	1.0.0-preview2-003131
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	7.0.2
	7.0.1
	7.0.0
	6.0.13
	6.0.12
	6.0.11
	6.0.10
	6.0.9
	6.0.3
	6.0.0
	3.1.32
	3.1.31
	3.1.30
	3.1.29
	3.1.23
	3.1.7
	2.2.1
	2.1.2
	2.1.0
	2.0.5
	2.0.0
	2.0.0-preview2-25319-02
	1.1.2
	1.1.1
	1.0.5
	1.0.4
	1.0.1

Xamarin.Profiler
Version: 1.8.0.19
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Xamarin.Android
Version: 13.1.0.1 (Visual Studio Enterprise)
Commit: xamarin-android/d17-4/13ba222
Android SDK: /Users/Aleksey/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0  (API level 23)
		12.0 (API level 31)
		13.0 (API level 33)

SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 33.0.2
SDK Build Tools Version: 32.0.0

Build Information: 
Mono: a96bde9
Java.Interop: xamarin/java.interop/d17-4@fcc33ce2
SQLite: xamarin/sqlite/3.39.3@23e1ae7
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@0be567a

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.16.1
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.4.0.54
Hash: 6eabb9e
Branch: remotes/origin/d17-4
Build date: 2023-01-12 19:21:16 UTC

Android Device Manager
Version: 0.0.0.1206
Hash: 886af39
Branch: 886af39
Build date: 2023-01-12 19:21:16 UTC

Apple Developer Tools
Xcode 14.2 (21534)
Build 14C18

Xamarin.Mac
Version: 9.0.0.27 (Visual Studio Enterprise)
Hash: 933c6c2c9
Branch: xcode14.1
Build date: 2022-11-22 02:00:36-0500

Xamarin.iOS
Version: 16.1.1.27 (Visual Studio Enterprise)
Hash: 933c6c2c9
Branch: xcode14.1
Build date: 2022-11-22 02:00:37-0500

Xamarin Designer
Version: 17.4.0.136
Hash: d49c9ff6d3
Branch: remotes/origin/d17-4
Build date: 2023-01-12 19:21:10 UTC

Build Information
Release ID: 1704030021
Git revision: 26eac6764d85f12fe50ee0d45a7cd0b266be7b23
Build date: 2023-01-12 19:19:02+00
Build branch: release-17.4
Build lane: release-17.4

Operating System
Mac OS X 12.6.2
Darwin 21.6.0 Darwin Kernel Version 21.6.0
    Sun Nov  6 23:31:16 PST 2022
    root:xnu-8020.240.14~1/RELEASE_X86_64 x86_64

Metadata

Metadata

Assignees

Labels

api-bindingsenhancementThe issue or pull request is an enhancementgood first issueThis is a good first issue for someone to start working with our code

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions