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

Attempted to construct an Id from a null pointer #51

Open
louis030195 opened this issue Jul 27, 2024 · 2 comments
Open

Attempted to construct an Id from a null pointer #51

louis030195 opened this issue Jul 27, 2024 · 2 comments

Comments

@louis030195
Copy link

After upgrading to mac 15.0 got this error:

thread '' panicked at /Users/matthewdi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_id-0.1.1/src/id.rs:52:9:
Attempted to construct an Id from a null pointer
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
libc++abi: terminating due to uncaught foreign exception
zsh: abort ./target/release/screenpipe --debug

Does not happen on mac 14.5 (m3)

using: RustAudio/cpal#894

we had to stop using screencapturekit-rs temporarily:
mediar-ai/screenpipe@e3ef919

sorry not lot of information, not sure where is the issue

happy to dig more in details / send a PR in upcoming days

@1313
Copy link
Collaborator

1313 commented Jul 29, 2024

Thanks for using this lib! I've been a bit in hibernation during summer but can have a look soon.

There is another take on macOS framework bindings which I think looks promising: https://github.com/yury/cidre check out the SC module.

Cheers
Per

@wangfu91
Copy link

wangfu91 commented Aug 9, 2024

Got the same error on macOS 15 beta. Here is the stack trace using the store_audio example:

thread '<unnamed>' panicked at /Users/fluffy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_id-0.1.1/src/id.rs:52:9:
Attempted to construct an Id from a null pointer
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/std/src/panicking.rs:693:12
   1: objc_id::id::Id<T,O>::from_ptr
             at /Users/fluffy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_id-0.1.1/src/id.rs:52:9
   2: screencapturekit_sys::cm_sample_buffer_ref::CMSampleBufferRef::get_frame_info
             at ./screencapturekit-sys/./src/cm_sample_buffer_ref.rs:25:13
   3: <store_audio::StoreAudioHandler as screencapturekit_sys::stream_output_handler::UnsafeSCStreamOutput>::did_output_sample_buffer
             at ./screencapturekit-sys/examples/store_audio.rs:66:33
   4: <screencapturekit_sys::stream_output_handler::UnsafeSCStreamOutputHandler as objc_foundation::object::INSObject>::class::{{closure}}::stream_output
             at ./screencapturekit-sys/./src/stream_output_handler.rs:53:21

I believe it is because the CMSampleBufferGetSampleAttachmentsArray API returns NULL, and the code didn't check for that:
https://github.com/svtlabs/screencapturekit-rs/blob/9a6b9f346bd30de0d2f9a02af36d4cf6461f4f3b/screencapturekit-sys/src/cm_sample_buffer_ref.rs#L23

A simple, temporary workaround I found is to set the createIfNecessary Bool parameter of CMSampleBufferGetSampleAttachmentsArray to true.

-- let raw_attachments_array = CMSampleBufferGetSampleAttachmentsArray(self, 0);
++ let raw_attachments_array = CMSampleBufferGetSampleAttachmentsArray(self, 1);

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

No branches or pull requests

3 participants