oxyroid / M3UAndroid

FOSS Player, which made of jetpack compose. Android 8.0 and above supported.
https://t.me/m3u_android
Apache License 2.0
440 stars 40 forks source link

Programmes from different sources, and the ProgrammeGuide may throw measure error #194

Open oxyroid opened 1 month ago

oxyroid commented 1 month ago

Describe the bug Currently, user can select multiple EPG sources for each playlist.

image

There are programmes in each channel of the playlist from different EPG sources after syncing programmes. The time range of the matched programmes may be very large, and the ProgrammeGuide component will try to draw a very large height rect in the canvas to place the component max height to keep the nice appearance.

image

Compose failed to measure such large height rect.

https://github.com/oxyroid/M3UAndroid/blob/master/feature/channel/src/main/java/com/m3u/feature/channel/components/ProgrammeGuide.kt#L216-L231

java.lang.IllegalArgumentException: Can't represent a width of 1440 and height of 620761 in Constraints
    at androidx.compose.ui.unit.ConstraintsKt.invalidConstraint(Constraints.kt:458)
    at androidx.compose.ui.unit.ConstraintsKt.createConstraints(Constraints.kt:485)
    at androidx.compose.ui.unit.Constraints$Companion.fixed-JhjzzOo(Constraints.kt:237)
    at eu.wewox.minabox.MinaBoxKt$MinaBox$1.invoke-0kLqBqw(MinaBox.kt:86)
    at eu.wewox.minabox.MinaBoxKt$MinaBox$1.invoke(MinaBox.kt:59)
    at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$3$2$1.invoke-0kLqBqw(LazyLayout.kt:119)
    at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$3$2$1.invoke(LazyLayout.kt:112)
    at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:725)
    at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:135)
    at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure-3p2s80s(GraphicsLayerModifier.kt:646)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:188)
    at androidx.compose.foundation.layout.FillNode.measure-3p2s80s(Size.kt:699)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:188)
    at androidx.compose.foundation.layout.FillNode.measure-3p2s80s(Size.kt:699)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:188)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:316)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:315)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:503)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:502)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:258)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1775)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:40)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:696)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:672)
    at androidx.compose.foundation.layout.BoxMeasurePolicy.measure-3p2s80s(Box.kt:173)
    at androidx.compose.foundation.layout.BoxWithConstraintsKt$BoxWithConstraints$1$1.invoke-0kLqBqw(BoxWithConstraints.kt:70)
    at androidx.compose.foundation.layout.BoxWithConstraintsKt$BoxWithConstraints$1$1.invoke(BoxWithConstraints.kt:67)
    at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:725)
    at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:135)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:316)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:315)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:503)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:502)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:258)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1775)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:40)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:696)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:672)
    at androidx.compose.foundation.layout.RowColumnMeasurePolicyKt.measure(RowColumnMeasurePolicy.kt:119)
    at androidx.compose.foundation.layout.RowColumnMeasurePolicyKt.measure$default(RowColumnMeasurePolicy.kt:74)
    at androidx.compose.foundation.layout.ColumnMeasurePolicy.measure-3p2s80s(Column.kt:207)
    at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:135)
    at androidx.compose.foundation.layout.PaddingNode.measure-3p2s80s(Padding.kt:414)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:188)
    at androidx.compose.foundation.layout.FillNode.measure-3p2s80s(Size.kt:699)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:188)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:316)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:315)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:503)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:502)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:258)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1775)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:40)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:696)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:672)
    at androidx.compose.foundation.layout.BoxMeasurePolicy.measure-3p2s80s(Box.kt:151)
    at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:135)
    at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure-3p2s80s(GraphicsLayerModifier.kt:646)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:188)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:316)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:315)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:503)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:502)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:258)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1775)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:40)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:696)
    at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:672)
    at com.m3u.material.components.PullPanelLayoutKt$PullPanelLayout$4.invoke$lambda$16$lambda$15(PullPanelLayout.kt:120)
    at com.m3u.material.components.PullPanelLayoutKt$PullPanelLayout$4.$r8$lambda$frBvY7_suKlUdJfCGDirR113ge8(Unknown Source:0)
    at com.m3u.material.components.PullPanelLayoutKt$PullPanelLayout$4$$ExternalSyntheticLambda1.invoke(Unknown Source:16)

We can just remove the placed rect but it has not been completely solved. There may be quite a bit of blank space between programs from different EPG sources.

We can change the strategy of matching programs from diff EPG source. We want to add a new concept called Matching Priority in playlist and EPG source association. User can drag the selected EPG source to change the priority in order to we can at most show programs from one EPG source which contains valid programs.

To Reproduce Steps to reproduce the behavior:

  1. Install v1.14.0-rc03
  2. Subscribe the playlist as below:
    https://live.fanmingming.com/tv/m3u/ipv6.m3u
  3. Subscribe each EPG source as below:
    http://epg.112114.xyz/pp.xml.gz
    http://epg.aptvapp.com/xml
  4. Press the playlist, then click the pencil icon.
  5. Select the two EPG sources, then click "Sync Programmes".
  6. Enter the playlist, play CCTV1, scroll up the player to show the programmes from different EPG sources.
  7. App Crash.

Expected behavior The component can at most show programmes from one EPG source which contains valid programmes and there is no measure error.

oxyroid commented 1 month ago

Relation Code: https://github.com/oxyroid/M3UAndroid/blob/master/data/src/main/java/com/m3u/data/database/dao/ProgrammeDao.kt#L23-L35 https://github.com/oxyroid/M3UAndroid/blob/master/data/src/main/java/com/m3u/data/database/model/Programme.kt https://github.com/oxyroid/M3UAndroid/blob/master/data/src/main/java/com/m3u/data/database/model/Playlist.kt#L54-L57 https://github.com/oxyroid/M3UAndroid/blob/master/data/src/main/java/com/m3u/data/database/model/Channel.kt#L54-L66 https://github.com/oxyroid/M3UAndroid/blob/master/data/src/main/java/com/m3u/data/repository/programme/ProgrammeRepositoryImpl.kt#L52-L74 https://github.com/oxyroid/M3UAndroid/blob/master/feature/channel/src/main/java/com/m3u/feature/channel/ChannelViewModel.kt#L281-L336 https://github.com/oxyroid/M3UAndroid/blob/master/feature/channel/src/main/java/com/m3u/feature/channel/components/ProgrammeGuide.kt#L216-L231