Opened 5 years ago

Last modified 5 years ago

#8365 new defect

AVFoundation video input hangs on iOS 12.4

Reported by: Arian Owned by:
Priority: normal Component: avdevice
Version: unspecified Keywords: avfoundation deadlock
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
Attempting video capture from any camera with the AVFoundation device on iOS 12.4 hangs ffmpeg. Capturing the microphone works fine, however.
Device is iPhone 6S (N71AP), I didn't test on any other iPhone or version.

iOS 11.2 SDK was used to compile, I can't compile on a Mac so I had to use the Theos SDK from github.com/theos/sdks.

Output of ffmpeg -f avfoundation -framerate 30 -pixel_format nv12 -i 0::

iPhone:~/FFmpeg-n4.2.1 mobile$ lldb ./ffmpeg_g
(lldb) target create "./ffmpeg_g"
Current executable set to './ffmpeg_g' (arm64).
(lldb) r -f avfoundation -framerate 30 -pixel_format nv12 -loglevel debug -i 0:
Process 46644 launched: './ffmpeg_g' (arm64)
ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with clang version 5.0.2
  configuration: --enable-indev=avfoundation --enable-hwaccel=videotoolbox --disable-debug --extra-cflags='-isysroot /User/iPhoneOS11.2.sdk' --extra-ldflags='-isysroot /User/iPhoneOS11.2.sdk' --disable-asm
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Splitting the commandline.
Reading option '-f' ... matched as option 'f' (force format) with argument 'avfoundation'.
Reading option '-framerate' ... matched as AVOption 'framerate' with argument '30'.
Reading option '-pixel_format' ... matched as AVOption 'pixel_format' with argument 'nv12'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-i' ... matched as input url with argument '0:'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url 0:.
Applying option f (force format) with argument avfoundation.
Successfully parsed a group of options.
Opening an input file: 0:.
[avfoundation @ 0x140002200] 'Back Camera' opened
(^C)
Process 46644 stopped
* thread #1: tid = 0x3faa7, 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8
libsystem_kernel.dylib`mach_msg_trap:
->  0x20eccc0f4 <+8>: ret    

libsystem_kernel.dylib`mach_msg_overwrite_trap:
    0x20eccc0f8 <+0>: movn   x16, #0x1f
    0x20eccc0fc <+4>: svc    #0x80
    0x20eccc100 <+8>: ret    
(lldb) bt
* thread #1: tid = 0x3faa7, 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x000000020eccb5a0 libsystem_kernel.dylib`mach_msg + 72
    frame #2: 0x000000020f0cc120 CoreFoundation`__CFRunLoopServiceMachPort + 236
    frame #3: 0x000000020f0c7030 CoreFoundation`__CFRunLoopRun + 1360
    frame #4: 0x000000020f0c67c0 CoreFoundation`CFRunLoopRunSpecific + 436
    frame #5: 0x0000000104622be4 ffmpeg_g`avf_read_header + 7636
    frame #6: 0x00000001048ea330 ffmpeg_g`avformat_open_input + 740
    frame #7: 0x0000000104603884 ffmpeg_g`open_input_file + 1408
    frame #8: 0x0000000104603198 ffmpeg_g`open_files + 288
    frame #9: 0x0000000104602f4c ffmpeg_g`ffmpeg_parse_options + 156
    frame #10: 0x0000000104615020 ffmpeg_g`main + 204
    frame #11: 0x000000020eb8a8e0 libdyld.dylib`start + 4

Trying again with microphone, this works:

(lldb) r -f avfoundation -loglevel debug -i :0
There is a running process, kill it and restart?: [Y/n] y
Process 46644 exited with status = 9 (0x00000009) 
Process 46646 launched: './ffmpeg_g' (arm64)
...
[avfoundation @ 0x104003800] audio device 'iPhone Microphone' opened
[avfoundation @ 0x104003800] All info found
Input #0, avfoundation, from ':0':
  Duration: N/A, start: 14092.105805, bitrate: 705 kb/s
    Stream #0:0, 1, 1/1000000: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
Successfully opened the file.
At least one output file must be specified
Process 46646 exited with status = 1 (0x00000001) 
(lldb) exit

Using another binary of version 4.1 yields the same issue:

(lldb) r -f avfoundation -framerate 30 -pixel_format nv12 -loglevel debug -i 0:
Process 46658 launched: '/usr/local/bin/ffmpeg' (arm64)
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with clang version 6.0.0-1ubuntu2~16.04.1 (tags/RELEASE_600/final)
  configuration: --enable-shared --enable-version3 --enable-pthreads --enable-hardcoded-tables --enable-avresample --cross-prefix=aarch64-apple-darwin17- --cc=aarch64-apple-darwin17-clang --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfdk-aac --enable-libopenh264 --enable-openssl --enable-libssh --enable-nonfree --arch=aarch64 --target-os=darwin --disable-sdl2
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Splitting the commandline.
Reading option '-f' ... matched as option 'f' (force format) with argument 'avfoundation'.
Reading option '-framerate' ... matched as AVOption 'framerate' with argument '30'.
Reading option '-pixel_format' ... matched as AVOption 'pixel_format' with argument 'nv12'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-i' ... matched as input url with argument '0:'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url 0:.
Applying option f (force format) with argument avfoundation.
Successfully parsed a group of options.
Opening an input file: 0:.
[avfoundation @ 0x14c003e00] 'Back Camera' opened
Process 46658 stopped
* thread #1: tid = 0x40506, 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8
libsystem_kernel.dylib`mach_msg_trap:
->  0x20eccc0f4 <+8>: ret    

libsystem_kernel.dylib`mach_msg_overwrite_trap:
    0x20eccc0f8 <+0>: movn   x16, #0x1f
    0x20eccc0fc <+4>: svc    #0x80
    0x20eccc100 <+8>: ret    
(lldb) bt
* thread #1: tid = 0x40506, 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x000000020eccb5a0 libsystem_kernel.dylib`mach_msg + 72
    frame #2: 0x000000020f0cc120 CoreFoundation`__CFRunLoopServiceMachPort + 236
    frame #3: 0x000000020f0c7030 CoreFoundation`__CFRunLoopRun + 1360
    frame #4: 0x000000020f0c67c0 CoreFoundation`CFRunLoopRunSpecific + 436
    frame #5: 0x000000010030393c libavdevice.58.dylib`___lldb_unnamed_function5$$libavdevice.58.dylib + 4456
    frame #6: 0x00000001007f0200 libavformat.58.dylib`avformat_open_input + 740
    frame #7: 0x0000000100288da0 ffmpeg`___lldb_unnamed_function2$$ffmpeg + 1448
    frame #8: 0x0000000100288684 ffmpeg`___lldb_unnamed_function1$$ffmpeg + 248
    frame #9: 0x0000000100288460 ffmpeg`ffmpeg_parse_options + 156
    frame #10: 0x000000010029a744 ffmpeg`main + 204
    frame #11: 0x000000020eb8a8e0 libdyld.dylib`start + 4
(lldb) exit

Change History (2)

comment:1 by Carl Eugen Hoyos, 5 years ago

Keywords: deadlock added; ios hang removed
Version: 4.2unspecified

Is the issue reproducible with current FFmpeg git head, the only version supported here?

in reply to:  1 comment:2 by Arian, 5 years ago

Replying to cehoyos:

Is the issue reproducible with current FFmpeg git head, the only version supported here?

Yes, I have just tried compiling the current ffmpeg version N-95635-gcae7f6658c and I get the exact same issue. I actually didn't omit --disable-debug this time and have a possibly more helpful backtrace:

ffmpeg version N-95635-gcae7f6658c Copyright (c) 2000-2019 the FFmpeg developers
  built with clang version 5.0.2
  configuration: --disable-everything --enable-indev=avfoundation --extra-cflags='-isysroot /User/iPhoneOS11.2.sdk' --extra-ldflags='-isysroot /User/iPhoneOS11.2.sdk' --disable-asm
...
Applying option f (force format) with argument avfoundation.
Successfully parsed a group of options.
Opening an input file: 1:.
[avfoundation @ 0x11c801800] 'Front Camera' opened
Process 56289 stopped
* thread #1: tid = 0x4c197, 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8
libsystem_kernel.dylib`mach_msg_trap:
->  0x20eccc0f4 <+8>: ret    

libsystem_kernel.dylib`mach_msg_overwrite_trap:
    0x20eccc0f8 <+0>: movn   x16, #0x1f
    0x20eccc0fc <+4>: svc    #0x80
    0x20eccc100 <+8>: ret    
(lldb) bt
* thread #1: tid = 0x4c197, 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x000000020eccc0f4 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x000000020eccb5a0 libsystem_kernel.dylib`mach_msg + 72
    frame #2: 0x000000020f0cc120 CoreFoundation`__CFRunLoopServiceMachPort + 236
    frame #3: 0x000000020f0c7030 CoreFoundation`__CFRunLoopRun + 1360
    frame #4: 0x000000020f0c67c0 CoreFoundation`CFRunLoopRunSpecific + 436
    frame #5: 0x00000001040c5e34 ffmpeg_g`avf_read_header [inlined] get_video_config(s=<unavailable>) + 72 at avfoundation.m:575
    frame #6: 0x00000001040c5dec ffmpeg_g`avf_read_header(s=<unavailable>) + 7564 at avfoundation.m:927
    frame #7: 0x00000001040e5510 ffmpeg_g`avformat_open_input(ps=0x000000016bd5eda8, filename=0x000000016bd5f70f, fmt=<unavailable>, options=0x000000011bd2ca38) + 740 at utils.c:633
    frame #8: 0x00000001040a6634 ffmpeg_g`open_input_file(o=0x000000016bd5eeb0, filename=<unavailable>) + 1408 at ffmpeg_opt.c:1105
    frame #9: 0x00000001040a5f48 ffmpeg_g`open_files(l=0x000000011bd2c528, inout=0x000000010419d86a, open_file=0x00000001040a60b4) + 288 at ffmpeg_opt.c:3283
    frame #10: 0x00000001040a5cfc ffmpeg_g`ffmpeg_parse_options(argc=<unavailable>, argv=<unavailable>) + 156 at ffmpeg_opt.c:3323
    frame #11: 0x00000001040b7e84 ffmpeg_g`main(argc=11, argv=0x000000016bd5f538) + 204 at ffmpeg.c:4863
    frame #12: 0x000000020eb8a8e0 libdyld.dylib`start + 4
Note: See TracTickets for help on using tickets.