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

[r2.14.0, rtsp library] setting repeat mode causes fatal error, resulting in force close #8994

Closed
warren-bank opened this issue May 29, 2021 · 14 comments
Assignees
Labels

Comments

@warren-bank
Copy link

logcat errors:
  05-29 12:15:00.692 26748-26882/com.github.warren_bank.exoplayer_airplay_receiver E/AndroidRuntime: FATAL EXCEPTION: ExoPlayer:Playback
      Process: com.github.warren_bank.exoplayer_airplay_receiver, PID: 26748
      java.lang.NullPointerException
          at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:154)
          at com.google.android.exoplayer2.source.rtsp.RtpDataLoadable.setTimestamp(RtpDataLoadable.java:111)
          at com.google.android.exoplayer2.source.rtsp.RtspMediaPeriod$InternalListener.onPlaybackStarted(RtspMediaPeriod.java:495)
          at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.onPlayResponseReceived(RtspClient.java:496)
          at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.onRtspMessageReceived(RtspClient.java:412)
          at com.google.android.exoplayer2.source.rtsp.RtspMessageChannel$Receiver.lambda$handleRtspMessage$0(RtspMessageChannel.java:291)
          at com.google.android.exoplayer2.source.rtsp.-$$Lambda$RtspMessageChannel$Receiver$frEfu1WfqENR1_7bFfrua9iV9BY.run(lambda)
          at android.os.Handler.handleCallback(Handler.java:733)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:136)
          at android.os.HandlerThread.run(HandlerThread.java:61)
  05-29 12:15:03.062 26748-26748/com.github.warren_bank.exoplayer_airplay_receiver E/EventLogger: playerFailed [eventTime=219.65, mediaPos=0.00, window=0, period=0
        com.google.android.exoplayer2.ExoPlaybackException: null error, index=-1, format=null, format_supported=YES
          at com.google.android.exoplayer2.SimpleExoPlayer.setVideoOutputInternal(SimpleExoPlayer.java:1922)
          at com.google.android.exoplayer2.SimpleExoPlayer.access$4000(SimpleExoPlayer.java:92)
          at com.google.android.exoplayer2.SimpleExoPlayer$ComponentListener.surfaceDestroyed(SimpleExoPlayer.java:2278)
          at android.view.SurfaceView.updateWindow(SurfaceView.java:556)
          at android.view.SurfaceView.access$000(SurfaceView.java:86)
          at android.view.SurfaceView$1.handleMessage(SurfaceView.java:129)
          at android.os.Handler.dispatchMessage(Handler.java:102)
          at android.os.Looper.loop(Looper.java:136)
          at android.app.ActivityThread.main(ActivityThread.java:5118)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
          at dalvik.system.NativeStart.main(Native Method)
       Caused by: com.google.android.exoplayer2.ExoTimeoutException: Detaching surface timed out.
          at com.google.android.exoplayer2.SimpleExoPlayer.setVideoOutputInternal(SimpleExoPlayer.java:1920)
          at com.google.android.exoplayer2.SimpleExoPlayer.access$4000(SimpleExoPlayer.java:92) 
          at com.google.android.exoplayer2.SimpleExoPlayer$ComponentListener.surfaceDestroyed(SimpleExoPlayer.java:2278) 
          at android.view.SurfaceView.updateWindow(SurfaceView.java:556) 
          at android.view.SurfaceView.access$000(SurfaceView.java:86) 
          at android.view.SurfaceView$1.handleMessage(SurfaceView.java:129) 
          at android.os.Handler.dispatchMessage(Handler.java:102) 
          at android.os.Looper.loop(Looper.java:136) 
          at android.app.ActivityThread.main(ActivityThread.java:5118) 
          at java.lang.reflect.Method.invokeNative(Native Method) 
          at java.lang.reflect.Method.invoke(Method.java:515) 
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606) 
          at dalvik.system.NativeStart.main(Native Method) 
      ]

quick trace through code to find cause:

  • method: RtpDataLoadable.setTimestamp
      public void setTimestamp(long timestamp) {
        if (!checkNotNull(extractor).hasReadFirstRtpPacket()) {...}
      }
  • method: RtpDataLoadable.load
      public void load() {
        extractor = new RtpExtractor(rtspMediaTrack.payloadFormat, trackId);
      }
  • inner class constructor: RtspMediaPeriod.RtpLoadInfo
      public RtpLoadInfo(...){
        this.loadable = new RtpDataLoadable(...);
      }
  • method: RtspMediaPeriod.getLoadableByTrackUri
      private RtpDataLoadable getLoadableByTrackUri(Uri trackUri) {
        RtpLoadInfo loadInfo = rtspLoaderWrappers.get(i).loadInfo;
        return loadInfo.loadable;
      }
  • method: RtspMediaPeriod.onPlaybackStarted
      public void onPlaybackStarted(...) {
        RtpDataLoadable dataLoadable = getLoadableByTrackUri(trackTiming.uri);
    
        // NEVER CALLS: dataLoadable.load();
    
        dataLoadable.setTimestamp(trackTiming.rtpTimestamp);
        // ERROR: dataLoadable.extractor is NULL
      }
warren-bank added a commit to warren-bank/Android-ExoPlayer-AirPlay-Receiver that referenced this issue May 29, 2021
RTSP announcements:
===================
https://exoplayer.dev/rtsp.html
https://github.com/google/ExoPlayer/blob/release-v2/RELEASENOTES.md#2140-2021-05-13
google/ExoPlayer#3854 (comment)

references:
===========
https://github.com/google/ExoPlayer/blob/r2.14.0/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java#L368
https://github.com/google/ExoPlayer/blob/r2.14.0/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java#L371
https://github.com/google/ExoPlayer/blob/r2.14.0/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java#L316
https://github.com/google/ExoPlayer/blob/r2.14.0/library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/RtspMediaSource.java#L123
https://github.com/google/ExoPlayer/blob/r2.14.0/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java#L221
https://github.com/google/ExoPlayer/blob/r2.14.0/library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaSource.java#L122
https://github.com/google/ExoPlayer/blob/r2.14.0/library/core/src/main/java/com/google/android/exoplayer2/upstream/RawResourceDataSource.java#L75
https://github.com/google/ExoPlayer/blob/r2.14.0/library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java#L58
https://github.com/google/ExoPlayer/blob/r2.14.0/library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java#L115
https://github.com/google/ExoPlayer/blob/r2.14.0/library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java#L79
https://github.com/google/ExoPlayer/blob/r2.14.0/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java#L215
https://github.com/google/ExoPlayer/blob/r2.14.0/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java#L91
https://github.com/google/ExoPlayer/blob/r2.14.0/library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java#L112
https://github.com/google/ExoPlayer/blob/r2.14.0/library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java
https://github.com/google/ExoPlayer/blob/r2.14.0/demos/main/src/main/java/com/google/android/exoplayer2/demo/TrackSelectionDialog.java#L356

issue:
======
google/ExoPlayer#8994
  - there appears to be a minor problem with RTSP support in r2.14.0
  - attempting to play an RTSP stream causes the app to crash
  - this should be resolved by updating ExoPlayer after a fix is released
    * TBD
@claincly
Copy link
Contributor

claincly commented Jun 1, 2021

Hello there, can you also post the RTSP messages? You can print the messages by following this simple step
#3854 (comment)

@warren-bank

This comment has been minimized.

@warren-bank

This comment has been minimized.

@claincly
Copy link
Contributor

claincly commented Jun 2, 2021

Sorry I meant the instructions to add the logs to see the actual exchanged RTSP messages.

To start, could you try plugging your link to any of RTSP links in
https://github.com/google/ExoPlayer/blob/d5d78238773d6dc53b54849ca10d845a4421284c/demos/main/src/main/assets/media.exolist.json
(just change any one uri, to "rtsp://..."), build the demo app, and see if it plays?

I can verify the link rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_175k.mov works in the demo app, let me see what else is wrong.

@warren-bank

This comment has been minimized.

@claincly
Copy link
Contributor

claincly commented Jun 2, 2021

Could you try building the player with a MediaSource.Factory instead of constructing a media source directly?

I.e., build your player using

Context context = getApplicationContext();
player =
    new SimpleExoPlayer.Builder(context)
         .setMediaSourceFactory(new DefaultMediaSourceFactory(context))
         .build();

And call player.setMediaItems() to set your MediaItem.

@warren-bank

This comment has been minimized.

@warren-bank

This comment has been minimized.

@warren-bank

This comment has been minimized.

@warren-bank

This comment has been minimized.

warren-bank added a commit to warren-bank/Android-ExoPlayer-AirPlay-Receiver that referenced this issue Jun 2, 2021
references:
===========
google/ExoPlayer#8994

important:
==========
* until this issue is resolved, a fatal error causing the app to crash
  will occur while playing an RTSP stream if the user changes "repeat mode"
@warren-bank
Copy link
Author

Bam!

OK, so the problem was this line:

  player.setRepeatMode(Player.REPEAT_MODE_ALL);
  • initialize the player with this line, and RTSP stream immediately causes a fatal error force closing the entire app
  • comment it out, and the RTSP stream plays properly
  • while the RTSP stream is playing:
    • if "repeat mode" is changed by the user using the GUI, a fatal error force closes the entire app

@warren-bank warren-bank changed the title [r2.14.0] rtsp.RtpDataLoadable.setTimestamp(): assertion failed: NullPointerException => extractor is null [r2.14.0, rtsp library] setting repeat mode causes fatal error, force close Jun 2, 2021
@warren-bank warren-bank changed the title [r2.14.0, rtsp library] setting repeat mode causes fatal error, force close [r2.14.0, rtsp library] setting repeat mode causes fatal error, resulting in force close Jun 2, 2021
warren-bank added a commit to warren-bank/Android-ExoPlayer-demos that referenced this issue Jun 2, 2021
* 5-rtsp-barebones-issue-8994
  - added (unofficial)
  - illustrates the fatal error in the RTSP library
    that causes the app to force close,
    as described by ExoPlayer issue 8994
      google/ExoPlayer#8994
@warren-bank
Copy link
Author

I made a very minimal app to demonstrate the error:

@ojw28
Copy link
Contributor

ojw28 commented Jun 2, 2021

@claincly - Note that RtspMediaSource needs to support creation of multiple RtspMediaPeriod instances, whose lifespans may overlap.

I think it might be a good idea to move toward a loading model like ProgressiveMediaSource, where the MediaSource doesn't load anything during preparation. Preparation completes immediately with a placeholder timeline. When a ProgressiveMediaPeriod is created later, it reports what's needed up to the parent ProgressiveMediaSource so that it can create and report the correct Timeline. This would let you move RtspClient instantiation down into RtspMediaPeriod, which I think would solve this problem.

@claincly
Copy link
Contributor

claincly commented Jun 8, 2021

Fixed in 1ca0efd.

@claincly claincly closed this as completed Jun 8, 2021
@google google locked and limited conversation to collaborators Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants