Closed parneet-guraya closed 11 months ago
2023-02-01 23:26:40.755 30841-30841 OplusScrollToTopManager com...mobiletools.musicplayer.debug D unregisterGuidePopupDismissReceiverInSystemUI
2023-02-01 23:26:40.755 30841-30841 OplusScrollToTopManager com...mobiletools.musicplayer.debug D Receiver not registered: android.view.OplusScrollToTopManager$1@c8cb134
2023-02-01 23:26:40.755 30841-30841 OplusScrollToTopManager com...mobiletools.musicplayer.debug D unregisterSystemUIBroadcastReceiver
2023-02-01 23:26:40.755 30841-30841 OplusScrollToTopManager com...mobiletools.musicplayer.debug D java.lang.IllegalArgumentException: Receiver not registered: android.view.OplusScrollToTopManager$2@81d7b5d
doesnt look like anything related
cause of issue found,
file is TrackActivity
@Subscribe(threadMode = ThreadMode.MAIN) fun trackChangedEvent(event: Events.TrackChanged) { val track = event.track if (track == null) { finish() } else { setupTrackInfo(event.track) } }
The function trackChangedEvent is called and the value of event.track is null which causes finish to get called.
@tibbi any idea why event.track is null?
@tibbi the function getQueuedTracks in the file MusicService.kt returns an empty arraylist the first time it is called, which is why this bug is seen.
Hi @tibbi I have a fix in place for this, but can't push the code. Is it an access issue, or should I be able to push it?
you can create a PR, you dont need access for it
@tibbi you can check the PR.
@tibbi
Hello, I was going through the code to find the possible cause. I found something that is related. As I am a beginner and my limited knowledge is speaking but these are things I noticed ->
Code is at the end!
ensureBackgroundThread block makes sure to run the code in background thread
In this it fetches the Artists -> Albums -> Tracks from Dao.
Tracks are initialised in this block.
Then there's runOnUiThread block which does the operations which should be done on the UI thread like dealing with views.
Here the tracks which are initialised in the background thread are passed to the TracksAdapter.
The problem (I think) is, for some reason (for the first time) the albums fetched are empty so does the tracks and they are passed to the TracksAdapter in the UI thread block.
But, the call to the dao for albums invokes again (for some reason) maybe the background thread is concurrently executing that. This time the albums are initialised with actual data and so does the tracks. But, then the UI thread block does not run. So, It is having the data from the first run which is empty.
Also when application is launched again it works fine. The problem persist for the fresh install and for the first time usage.
override fun setupFragment(activity: BaseSimpleActivity) {
ensureBackgroundThread {
val albums = ArrayList<Album>()
val artists = context.artistDAO.getAll()
artists.forEach { artist ->
albums.addAll(context.albumsDAO.getArtistAlbums(artist.id))
}
Log.d(LOG_TAG,"Albums init inside TracksFragment -> ${albums.size}")
var tracks = ArrayList<Track>()
albums.forEach { album ->
tracks.addAll(context.tracksDAO.getTracksFromAlbum(album.id))
}
tracks = tracks.distinctBy { "${it.path}/${it.mediaStoreId}" }.toMutableList() as ArrayList<Track>
val excludedFolders = context.config.excludedFolders
tracks = tracks.filter {
!excludedFolders.contains(it.path.getParentPath())
}.toMutableList() as ArrayList<Track>
Track.sorting = context.config.trackSorting
tracks.sort()
tracksIgnoringSearch = tracks
Log.d(LOG_TAG,"Tracks init inside TracksFragment -> ${tracks.size}")
activity.runOnUiThread {
tracks_placeholder.text = context.getString(R.string.no_items_found)
tracks_placeholder.beVisibleIf(tracks.isEmpty())
val adapter = tracks_list.adapter
if (adapter == null) {
Log.d(LOG_TAG,"TracksAdapter(tracks) in TracksFragment -> $tracks")
TracksAdapter(activity, tracks, false, tracks_list) {
activity.hideKeyboard()
activity.handleNotificationPermission { granted ->
if (granted) {
activity.resetQueueItems(tracks) {
Intent(activity, TrackActivity::class.java).apply {
putExtra(TRACK, Gson().toJson(it))
putExtra(RESTART_PLAYER, true)
activity.startActivity(this)
}
}
} else {
if (context is Activity) {
PermissionRequiredDialog(activity, R.string.allow_notifications_music_player)
}
}
}
}.apply {
tracks_list.adapter = this
}
if (context.areSystemAnimationsEnabled) {
tracks_list.scheduleLayoutAnimation()
}
} else {
(adapter as TracksAdapter).updateItems(tracks)
}
}
}
}
Any idea what's causing this?
Thanks Parneet
Hello! @parneet-guraya @tanaytandon12
I have uploaded a test APK with a possible fix for this issue, please check if you are interested: https://github.com/Naveen3Singh/Simple-Music-Player/releases/download/improved_media_scan/music-player-prepaid-debug.apk
Let me know if it works, thanks.
Yup, It works fine! What changes did you make? What was causing it? Was I any way near with that my comment?
Simply converted the local variable to a global one. Like in @tanaytandon12's PR.
@parneet-guraya @naveen3singh is my telegram username.
https://user-images.githubusercontent.com/111801812/215437896-2fe24116-3013-4b72-a8ba-a12dba974999.mp4
As of 30/01/23 Version- 5.16.3![Screenshot_2023-01-30-15-00-53-85_fc704e6b13c4fb26bf5e411f75da84f2](https://user-images.githubusercontent.com/111801812/215439472-a42301bf-d4e5-4f1c-84bb-cf99849d648f.jpg)