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

fix: when setPreviewSurfaces is not called startEncoding gives a null Pointer #3125

Merged

Conversation

jffp113
Copy link
Contributor

@jffp113 jffp113 commented Dec 19, 2022

Description of changes:

When using the kinesis video stream SDK without any preview surface, the android app closes abruptly with a Null pointer exception.
This happens because setPreviewSurface is the only place that initializes the mPreviewSurfaces. This variable will be passed to startEncoding that will use it as initialized (non null).
I choose to initialize with a LinkedList to have less upfront cost because this variable will be overridden when setPreviewSurface is called.

The exception that lead me to do this change:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.myapplication, PID: 15958 java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object[] java.util.Collection.toArray()' on a null object reference at java.util.ArrayList.addAll(ArrayList.java:588) at com.amazonaws.mobileconnectors.kinesisvideo.camera.CameraFramesSource.startEncoding(CameraFramesSource.java:84) at com.amazonaws.mobileconnectors.kinesisvideo.mediasource.android.AndroidCameraMediaSource.startEncoding(AndroidCameraMediaSource.java:224) at com.amazonaws.mobileconnectors.kinesisvideo.mediasource.android.AndroidCameraMediaSource.start(AndroidCameraMediaSource.java:196) at com.amazonaws.kinesisvideo.internal.client.AbstractKinesisVideoClient.startAllMediaSources(AbstractKinesisVideoClient.java:93)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jffp113 jffp113 requested a review from a team as a code owner December 19, 2022 16:11
@tylerjroach
Copy link
Member

Hi @jffp113, thank you for the contribution. Our team will triage this and take a look.

@tjleing tjleing merged commit 14d7a3d into aws-amplify:main Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants