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

Build breaks in video.swift #855

Closed
jjedele opened this issue Mar 15, 2020 · 11 comments
Closed

Build breaks in video.swift #855

jjedele opened this issue Mar 15, 2020 · 11 comments

Comments

@jjedele
Copy link

jjedele commented Mar 15, 2020

When trying to build the current master, it fails for me in video.swift with following error:

ERROR: /Users/jeff/repos/io/tools/build/swift/BUILD:17:1: Compiling Swift module video failed (Exit 1)
tensorflow_io/core/swift/video.swift:40:12: error: value of type 'CMSampleBuffer' has no member 'numSamples'
        if sampleBuffer.numSamples != 1 {
           ^~~~~~~~~~~~ ~~~~~~~~~~
tensorflow_io/core/swift/video.swift:41:40: error: value of type 'CMSampleBuffer' has no member 'numSamples'
            print("number of samples \(sampleBuffer.numSamples) is not supported")
                                       ^~~~~~~~~~~~ ~~~~~~~~~~
tensorflow_io/core/swift/video.swift:93:9: warning: initialization of immutable value 'deviceName' was never used; consider replacing with assignment to '_' or removing it
    let deviceName = String(cString: devname)
    ~~~~^~~~~~~~~~
    _
tensorflow_io/core/swift/video.swift:138:16: warning: comparing non-optional value of type 'UnsafeMutablePointer<VideoContext>' (aka 'UnsafeMutablePointer<(session: AVCaptureSession, semaphore_in: DispatchSemaphore, semaphore_out: DispatchSemaphore, delegate: VideoDataOutputSampleBufferDelegate)>') to 'nil' always returns true
    if context != nil {
       ~~~~~~~ ^  ~~~
tensorflow_io/core/swift/video.swift:158:16: warning: comparing non-optional value of type 'UnsafeMutablePointer<VideoContext>' (aka 'UnsafeMutablePointer<(session: AVCaptureSession, semaphore_in: DispatchSemaphore, semaphore_out: DispatchSemaphore, delegate: VideoDataOutputSampleBufferDelegate)>') to 'nil' always returns true
    if context != nil {
       ~~~~~~~ ^  ~~~

I did expunge and rebuild 2 times, but it didn't help. Also when I look at the CMSampleBuffer API Docs, there is only a sampleCount and no numSamples attribute in there.

Any ideas what the problem could be?

@yongtang
Copy link
Member

@jjedele Do you know the Xcode version you are using? Maybe it is the version mismatch as the numSamples is in the docs:
https://developer.apple.com/documentation/coremedia/cmsamplebuffer

@jjedele
Copy link
Author

jjedele commented Mar 15, 2020

@yongtang 10.3. I will update it and see write here if it works helps.

@yongtang
Copy link
Member

@jjedele My Xcode is 11.3.1, let me know if upgrade works. Otherwise I can try to see if I can update the code to support both Xcode 10 and Xcode 11.

@jjedele
Copy link
Author

jjedele commented Mar 15, 2020

@yongtang I updated Xcode and now it builds, but when I'm trying to load the library I get following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jeff/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/framework/load_library.py", line 152, in load_library
    py_tf.TF_LoadLibrary(lib)
tensorflow.python.framework.errors_impl.NotFoundError: dlopen(bazel-bin/tensorflow_io/core/python/ops/libtensorflow_io.so, 6): Symbol not found: _$sSo17CMSampleBufferRefa9CoreMediaE10numSamplesSivg
  Referenced from: bazel-bin/tensorflow_io/core/python/ops/libtensorflow_io.so (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/swift/libswiftCoreMedia.dylib
 in bazel-bin/tensorflow_io/core/python/ops/libtensorflow_io.so

Seems I have to update something else. Hope it's not the whole OS. Looking into it.

@jjedele
Copy link
Author

jjedele commented Mar 15, 2020

Xcode now also 11.3.1, OSX 10.14.6.

@yongtang
Copy link
Member

@jjedele It looks like it is due to the Swift 5 Runtime? Though I am not so sure. In old versions of macOS the Runtime needs to be installed separately, but 10.14.6 could be new enough already.

@jjedele
Copy link
Author

jjedele commented Mar 18, 2020

@yongtang Haven't been able to figure this out yet unfortunately. Apparently Swift 5 is in XCode 11.3 which I have installed. Is there an way to deactivate compiling the Swift parts selectively?

@yongtang
Copy link
Member

Is there an way to deactivate compiling the Swift parts selectively?

@jjedele It may not be straightforward though you could:

  1. In tensorflow_io/core/BUILD remove line 216 "//tools/build/swift:audio_swift",
  2. In tensorflow_io/core/BUILD remove line 236 "//tools/build/swift:video_swift",
  3. In tensorflow_io/core/kernels/audio_mp4_kernels.cc remove line 23-33 so that you have dump functions: https://github.com/tensorflow/io/blob/master/tensorflow_io/core/kernels/audio_mp4_kernels.cc#L23-L33
  4. In tensorflow_io/core/kernels/video_kernels.cc remove line 20-24 so that you have dummy functions: https://github.com/tensorflow/io/blob/master/tensorflow_io/core/kernels/video_kernels.cc#L20-L24

After that you can selectively build .so only:

bazel build -s --verbose_failures //tensorflow_io/core:python/ops/libtensorflow_io.so

@jjedele
Copy link
Author

jjedele commented Mar 19, 2020

@yongtang Thx, that kind of worked. Unfortunately I'm now back to (like before the Kafka update)

tensorflow.python.framework.errors_impl.NotFoundError: dlopen(bazel-bin/tensorflow_io/core/python/ops/libtensorflow_io.so, 6): Symbol not found: _timespec_get
  Referenced from: bazel-bin/tensorflow_io/core/python/ops/libtensorflow_io.so (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libSystem.B.dylib
 in bazel-bin/tensorflow_io/core/python/ops/libtensorflow_io.so

I'm getting the feeling that something's messed up with my environment, it somehow also says the library is built for OSX 10.15 despite I'm on 10.14.

@yongtang
Copy link
Member

Ah, I think you may need to pass

            --copt -mmacosx-version-min=10.13 \
            --linkopt -mmacosx-version-min=10.13 

to bazel, so:

bazel build -s \
    --copt -mmacosx-version-min=10.13 \
    --linkopt -mmacosx-version-min=10.13 \
 --verbose_failures //tensorflow_io......

We actually passes those two options in our CI:
https://github.com/tensorflow/io/blob/master/.github/workflows/build.yml#L84-L106

So it was not getting noticed. Probably should pass those two options in .bazelrc (created from https://github.com/tensorflow/io/blob/master/tools/build/configure.py#L104-L106 ), so that it is not needed to pass that two long options in command line.

@yongtang
Copy link
Member

@jjedele The issue should have been fixed by #953. All usage of 10.15 APIs in swift have been removed. You still need to pass `--copt="-mmacosx-version-min=10.13" and --linkopt="-mmacosx-verson-min=10.13" to bazel build, then build will be successful.

I will close this issue for now, but feel free to re-open if the issue persists.

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

2 participants