Closed MrWhhh closed 8 months ago
Hello @MrWhhh,
The information you provided is not enough to make it actionable for us. It would be useful to see what device you used and clear steps to reproduce the issue.
It would also be useful to see the bug report. If you're unable to share bug reports or test content publicly, please send them to android-media-github@google.com using a subject "Issue #903". Please also update this issue to indicate you’ve done this.
@oceanjules The device I use is Huawei mate60pro, the system is Hongmeng4, and the music playing service is inherited from MediaLibraryService(). When I call exoplayer to play, other devices can normally send notifications and play, but there is a crash on Huawei mate60pro. Error log as above
I have also encountered this error. It appears on the Huawei P40, and HarmonyOS 4 must appear.
When I turn off all notification permissions of the APP, there will be no crash, so this error should be a crash caused by the notification.
@MrWhhh Please provide repro steps with the demo app if you want us look into this. If we don't know how to repro we probably work on other issues first that are more actionable. I'm not sure when and whether we get such a Huawei device in our hands, but if we do and we don't have the repro steps with the demo app, it would be unfortunate.
Regarding this happening on Huawei only: while being not a politician nor a prophet - I'd also try to talk to Huawei directly. Personally, I have taken notice of Hongmeng4
in this issue for the first time. You know that story behind it probably better then I do.
@marcbaechinger
browserFuture = MediaBrowser.Builder(
this,
SessionToken(
this,
ComponentName(this, MusicService::class.java)
)
)
.buildAsync()
serivce inherits from MediaLibraryService() in the same way as Demo
class MusicService : MediaLibraryService() {
lateinit var player: ExoPlayer
lateinit var mediaLibrarySession: MediaLibrarySession
private val serviceScope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
override fun onCreate() {
super.onCreate()
player = ExoPlayer.Builder(this)
.setAudioAttributes(AudioAttributes.DEFAULT, !DataStoreEnum.RESTS_APP_PLAY.read(false))
.setHandleAudioBecomingNoisy(true)
.build()
player.addListener(MyPlayer())
val forwardingPlayer = @OptIn(UnstableApi::class) object : ForwardingPlayer(player){}
mediaLibrarySession =
MediaLibrarySession
.Builder(this, forwardingPlayer, MySessionCallback())
.build()
}
override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaLibrarySession? =
mediaLibrarySession
override fun onDestroy() {
serviceScope.cancel()
player.release()
mediaLibrarySession.release()
super.onDestroy()
}
}
@MrWhhh Please provide repro steps with the demo app if you want us look into this.
I myself pull the source code in the HarmonyOS 4 phone debugging found that the following code may cause long overflow exception.
long playbackStartTimeMs = getPlaybackStartTimeEpochMs(player);
boolean displayElapsedTimeWithChronometer = playbackStartTimeMs != C.TIME_UNSET;
builder
.setWhen(playbackStartTimeMs)
.setShowWhen(displayElapsedTimeWithChronometer)
.setUsesChronometer(displayElapsedTimeWithChronometer);
getPlaybackStartTimeEpochMs method returns the value Long.MIN_VALUE + 1 and then sets the setWhen method to have a long overflow exception. I tried to divide the value by 2 and it was normal.
@WXFY Thanks for investigation and reporting.
setWhen
is documented to be the time at which the event occured. So setting C.TIME_UNSET
as we do isn't correct and we can avoid this with a trivial change I think:
builder
.setWhen(displayElapsedTimeWithChronometer ? playbackStartTimeMs : 0L)
.setShowWhen(displayElapsedTimeWithChronometer)
.setUsesChronometer(displayElapsedTimeWithChronometer);
I think a time at which the event occurred
shouldn't be a negative value. I sent the change above in DefaultMediaNotificationProvider
for review as it seems we violate what is documented. There will be an entry in this issue when the change lands here on GitHub.
It looks like this isn't a problem on other devices, I have tested the code below with API 28 and API 34 on Pixels and I can not repro the crash:
long playbackStartTimeMs = getPlaybackStartTimeEpochMs(player);
boolean displayElapsedTimeWithChronometer = playbackStartTimeMs != C.TIME_UNSET;
builder
.setWhen(C.TIME_UNSET)
.setShowWhen(displayElapsedTimeWithChronometer)
.setUsesChronometer(displayElapsedTimeWithChronometer);
If you wanna do me a favor and you have the source already available, you can test the proposed fix above and test with the HarmonyOS 4 device to verify this actually helps.
@WXFY Thanks for investigation and reporting.
setWhen
is documented to be the time at which the event occured. So settingC.TIME_UNSET
as we do isn't correct and we can avoid this with a trivial change I think:builder .setWhen(displayElapsedTimeWithChronometer ? playbackStartTimeMs : 0L) .setShowWhen(displayElapsedTimeWithChronometer) .setUsesChronometer(displayElapsedTimeWithChronometer);
I think
a time at which the event occurred
shouldn't be a negative value. I sent the change above inDefaultMediaNotificationProvider
for review as it seems we violate what is documented. There will be an entry in this issue when the change lands here on GitHub.It looks like this isn't a problem on other devices, I have tested the code below with API 28 and API 34 on Pixels and I can not repro the crash:
long playbackStartTimeMs = getPlaybackStartTimeEpochMs(player); boolean displayElapsedTimeWithChronometer = playbackStartTimeMs != C.TIME_UNSET; builder .setWhen(C.TIME_UNSET) .setShowWhen(displayElapsedTimeWithChronometer) .setUsesChronometer(displayElapsedTimeWithChronometer);
If you wanna do me a favor and you have the source already available, you can test the proposed fix above and test with the HarmonyOS 4 device to verify this actually helps.
I tested the Huawei P40 HarmonyOS 4 with your modified code and it works normally.
Thanks for confirming. I'm closing this issue as the fix seems to work.
Version
Media3 1.2.0
More version details
Devices that reproduce the issue
Huawei
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
lay
Expected result
Media playback success
Actual result
Media
all meida
Bug Report
adb bugreport
to android-media-github@google.com after filing this issue.