I know that it is not the best title in the world but let me explain the problem first,
I have implemented a Glance widget with some items in it and when you press them, the app should be opened and navigated to the specific screen given via deep-link in NavHost. However, sometimes the page navigated via deep-link works and sometimes not. When it is not, got an error something like this:
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4d in tid 2486 (DefaultDispatch), pid 2259
I believe this is a segmentation error as I pass the argument from widget to app by using Gson()toJson(itemData). However, I do not understand why this sometimes works as I use the same thing for each item in order to open the app and navigate to the details screen.
The other thing is when the app does not crash with that error, the app directly opens the details page rather than showing the splash screen first and navigating to the detail screen.
In the end, how can I solve that segmentation error during deep-linking and how can I prepopulate the backstack(or just first navigate to splash and then to detail screen)?
For some more information, there is a sample code:
// CODE IN GLANCE WIDGET
@Composable
private fun Item(
model: ItemData,
) {
val intent = Intent(
Intent.ACTION_VIEW,
"${URL}/${Screens.DetailScreen.passArgument(model.toDetailData())}".toUri() // pass model just converts detailData to string with Gson().toJson()
)
Text(
text = model.title ?: "",
modifier = GlanceModifier
.clickable(
actionStartActivity(
intent
)
)
)
}
// CODE IN NAVHOST
NavHost(
// navhost parameters such as route, controller, start destination
// where start destination set to Splash Screen
){
composable(/*routeOfSpashScreen*/){SplashScreen}
.
. // These dots are some sub-navGraphs
.
.
detailScreenNavGraph()
}
// DETAIL SCREEN SUB-NAVGRAPH
fun NavGraphBuilder.detailScreenNavGraph(
controller: NavHostController? = null // This is optional and does not relate to problem
) {
navigation(
startDestination = Screens.DetailScreen.route,
route = DETAIL_SCREEN_ROUTE
) {
composable(
route = Screens.DetailScreen.route + "/{model}",
arguments = listOf(
navArgument(
name = "model"
) {
type = DetailDataNavType()
},
),
deepLinks = listOf(
navDeepLink {
uriPattern = "${URL}/" + Screens.DetailScreen.route + "/{model}"
}
)
) {
val model = it.arguments?.getParcelable<DetailData>("model")
if (model != null) {
DetailScreen(
model,
controller = controller ?: LocalNavigationManager.current
)
}
}
}
}
Any help or advice is appreciated.