Skip to content

Commit 2454826

Browse files
authored
Merge pull request #791 from 100mslive/fix-preview-null-localpeer-crash
Fix PreviewFragment's Null-Localpeer crash
2 parents 8e12e63 + afe813c commit 2454826

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
1717
android.useAndroidX=true
1818
# Kotlin code style for this project: "official" or "obsolete":
1919
kotlin.code.style=official
20-
100MS_APP_VERSION_CODE=380
21-
100MS_APP_VERSION_NAME=5.0.15
20+
100MS_APP_VERSION_CODE=381
21+
100MS_APP_VERSION_NAME=5.0.16
2222
hmsRoomKitGroup=live.100ms
23-
HMS_ROOM_KIT_VERSION=1.3.2
24-
HMS_SDK_VERSION=2.9.78
23+
HMS_ROOM_KIT_VERSION=1.3.3
24+
HMS_SDK_VERSION=2.9.79
2525
# Common publishing info
2626
publishing_licence_name="MIT License"
2727
publishing_licence_url="http://www.opensource.org/licenses/mit-license.php"

room-kit/src/main/java/live/hms/roomkit/ui/meeting/PreviewFragment.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class PreviewFragment : Fragment() {
106106
if (binding.buttonJoinMeeting.drawableStart == null) {
107107
binding.buttonJoinMeeting.setDrawables(
108108
start = ContextCompat.getDrawable(
109-
context!!, R.drawable.ic_live
109+
requireContext(), R.drawable.ic_live
110110
)
111111
)
112112
}
@@ -667,7 +667,16 @@ class PreviewFragment : Fragment() {
667667
enableDisableJoinNowButton()
668668

669669
updateUiBasedOnPublishParams(room.localPeer?.hmsRole?.publishParams)
670-
track = MeetingTrack(room.localPeer!!, null, null)
670+
671+
// Guard against null localPeer during SDK initialization race condition.
672+
// Return early to prevent NPE crash - UI will update via other lifecycle events
673+
val localPeer = room.localPeer
674+
if (localPeer == null) {
675+
Log.e(TAG, "LocalPeer is null in previewUpdateLiveData observer, skipping video initialization")
676+
return@Observer
677+
}
678+
679+
track = MeetingTrack(localPeer, null, null)
671680
localTracks.forEach {
672681
when (it) {
673682
is HMSLocalAudioTrack -> {
@@ -687,8 +696,8 @@ class PreviewFragment : Fragment() {
687696

688697
binding.editTextName.doOnTextChanged { text, start, before, count ->
689698
if (text.isNullOrEmpty().not()) {
690-
val intitals = kotlin.runCatching { NameUtils.getInitials(text.toString()) }
691-
binding.nameInitials.text = intitals.getOrNull().orEmpty()
699+
val initials = kotlin.runCatching { NameUtils.getInitials(text.toString()) }
700+
binding.nameInitials.text = initials.getOrNull().orEmpty()
692701
binding.noNameIv.visibility = View.GONE
693702
} else {
694703
binding.nameInitials.text = ""

0 commit comments

Comments
 (0)