[BUG] When I show or hide a using a condition, the app may crash if the PdfRendererViewCompose has not finished rendering its page
š Describe the Bug
Iām using Jetpack Compose. When I show or hide a PdfRendererViewCompose using a if condition, the app may crash if the PdfRendererViewCompose has not finished rendering its page ā for example, if the PDF is still loading or the user is switching to the next page and rendering is in progress.
The crash does not provide a detailed stack trace. The only output in logcat is:
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x70 in tid 13729 (DefaultDispatch), pid 13679 (x)
š Library Version
2.3.7
š¶ Steps to Reproduce
Please follow these steps to reproduce the issue:
- Display a
PdfRendererViewComposein a Compose screen. - Start loading a PDF or scroll to switch pages.
- While rendering is in progress, trigger the
ifcondition to remove or hide thePdfRendererViewCompose.
š¤ Expected Behavior
Confirm if my usage issue is still the current problem with PdfViewer
š» Code Snippets
if (showPdf && viewModel.pdfFile != null) {
var loadingPdf by remember { mutableStateOf(true) }
Box(
modifier = Modifier
.fillMaxSize()
.background(Color(0xCC222222)),
contentAlignment = Alignment.BottomCenter
) {
Box(
modifier = Modifier
.padding(36.dp)
.size(64.dp)
.clip(CircleShape)
.background(Color(0x80FFFFFF))
.align(Alignment.TopStart)
.clickable {
showPdf = false
viewModel.pdfFile = null
}
) {
Icon(
imageVector = Icons.Default.Close,
contentDescription = null,
tint = Color.White,
modifier = Modifier
.fillMaxSize()
.padding(12.dp)
)
}
Box(
modifier = Modifier
.fillMaxHeight()
.aspectRatio(0.75f)
) {
if (loadingPdf) {
CircularProgressIndicator(
color = Color.White, modifier = Modifier
.size(128.dp)
.align(Alignment.Center)
)
}
PdfRendererViewCompose(
source = PdfSource.LocalFile(viewModel.pdfFile!!.file),
lifecycleOwner = LocalLifecycleOwner.current,
cacheStrategy = CacheStrategy.DISABLE_CACHE,
statusCallBack = object : PdfRendererView.StatusCallBack {
override fun onPdfLoadStart() {
Log.d("xxxPDF", "onPdfLoadStart")
}
override fun onPdfLoadProgress(progress: Int, downloadedBytes: Long, totalBytes: Long?) {
Log.d("xxxPDF", "onPdfLoadProgress: progress= ${progress}, downloadedBytes= ${downloadedBytes}, totalBytes= $totalBytes")
}
override fun onPdfLoadSuccess(absolutePath: String) {
Log.d("xxxPDF", "onPdfLoadSuccess: absolutePath= $absolutePath")
}
override fun onError(error: Throwable) {
Log.d("xxxPDF", "onError: error= ${error.stackTraceToString()}")
}
override fun onPageChanged(currentPage: Int, totalPage: Int) {
Log.d("xxxPDF", "onPageChanged: currentPage= ${currentPage}, totalPage= $totalPage")
}
override fun onPdfRenderStart() {
Log.d("xxxPDF", "onPdfRenderStart")
}
override fun onPdfRenderSuccess() {
Log.d("xxxPDF", "onPdfRenderSuccess")
}
},
modifier = Modifier.fillMaxSize()
)
}
}
}
š Log Output/Stack Trace
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x70 in tid 13729 (DefaultDispatch), pid 13679 (x)
Thank you for creating your first issue. We appreciate your help in making this project better. We will look into it, and get back to you soon. Need help or want to discuss this issue? Join our Discord community here to ask questions and discuss this issue live!
Have the same issue, same stack trace:
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x70 in tid 21584 (DefaultDispatch), pid 11833 (x)