Priyanshu Jain
09/04/2023, 10:49 AM@Composable
expect fun font(res: String, weight: FontWeight, style: FontStyle = FontStyle.Normal): Font
And the iosMain actual implementation is:
@OptIn(ExperimentalResourceApi::class)
@Composable
actual fun font(res: String, weight: FontWeight, style: FontStyle): Font {
return cache.getOrPut(res) {
val byteArray = runBlocking {
resource("font/$res.ttf").readBytes()
}
Font(res, byteArray, weight, style)
}
}
Error Log:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: UNKNOWN_0xD at 0x0000000000000000
Exception Codes: 0x000000000000000d, 0x0000000000000000
VM Region Info: 0 is not in any region. Bytes before following region: 4423217152
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 107a4f000-109ba7000 [ 33.3M] r-x/r-x SM=COW ....app/MyApp
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [54296]
Triggered by Thread: 0
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 MyApp 0x108dbc62f IsInstance + 15
1 MyApp 0x107cdd19c kfun:androidx.compose.runtime.CompositionImpl#composeContent(kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>){} + 1020
2 MyApp 0x107d107d6 kfun:androidx.compose.runtime.Recomposer#composeInitial(androidx.compose.runtime.ControlledComposition;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>){} + 1350
3 MyApp 0x107cc29a9 kfun:androidx.compose.runtime.ComposerImpl.CompositionContextImpl.composeInitial#internal + 265
4 MyApp 0x107cdc325 kfun:androidx.compose.runtime.CompositionImpl#setContent(kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>){} + 581
5 MyApp 0x10814447a kfun:androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcomposeInto#internal + 762
6 MyApp 0x108143f9d kfun:androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose#internal.158 + 1373
7 MyApp 0x1081439b2 kfun:androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose#internal + 1554
8 MyApp 0x10814317b kfun:androidx.compose.ui.layout.LayoutNodeSubcompositionsState#subcompose(kotlin.Any?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>){}kotlin.collections.List<androidx.compose.ui.layout.Measurable> + 3595
9 MyApp 0x108149b65 kfun:androidx.compose.ui.layout.LayoutNodeSubcompositionsState.Scope.subcompose#internal + 149
10 MyApp 0x108796a63 kfun:androidx.compose.material3.ScaffoldLayout$lambda$6$lambda$5#internal + 19603
The complete error log is quite long, so I have attached it below. Am I making a mistake somewhere or have things changed with v1.5.0.Alexander Maryanovsky
09/04/2023, 1:48 PMPriyanshu Jain
09/04/2023, 1:53 PMbyteArray = [..., ..., ..., , ...]
as the value after the readBytes operation.Alexander Maryanovsky
09/04/2023, 1:56 PMPriyanshu Jain
09/04/2023, 2:28 PMprivate fun hash(key: K) = if (key == null) 0 else (key.hashCode() * MAGIC) ushr hashShift
And I get this exception in the debugger:
Exception = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
Priyanshu Jain
09/04/2023, 2:31 PMprivate val cache: MutableMap<String, Font> = mutableMapOf()
Alexander Maryanovsky
09/04/2023, 2:32 PMAlexander Maryanovsky
09/04/2023, 2:34 PMPriyanshu Jain
09/04/2023, 2:40 PMkotlin.collections.HashMap.hash#internal HashMap.kt:218
HashMap#addKey HashMap.kt:294
HashSet#add HashSet.kt:37
kotlin.Throwable.ExceptionTraceBuilder.dumpSelfTrace#internal Throwable.kt:94
kotlin.Throwable.ExceptionTraceBuilder.dumpFullTrace#internal Throwable.kt:84
kotlin.Throwable.ExceptionTraceBuilder.print#internal Throwable.kt:71
Throwable#printStackTrace Throwable.kt:55
ReportUnhandledException RuntimeUtils.kt:153
(anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1::operator()() const 0x0000000103307e09
void (anonymous namespace)::$_0::operator()<(anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1>((anonymous namespace)::terminateWithUnhandledException(ObjHeader*)::$_1) 0x0000000103307cdf
(anonymous namespace)::terminateWithUnhandledException(ObjHeader*) 0x0000000103307af9
(anonymous namespace)::processUnhandledException(ObjHeader*) 0x0000000103307ab7
(anonymous namespace)::TerminateHandler::kotlinHandler() 0x00000001033077cc
std::__terminate(void (*)()) 0x00007ff800257b65
__cxa_rethrow 0x00007ff80025a3a4
objc_exception_rethrow 0x00007ff80004dd0d
CFRunLoopRunSpecific 0x00007ff800381769
GSEventRunModal 0x00007ff809cb128a
-[UIApplication _run] 0x0000000107434ad3
UIApplicationMain 0x00000001074399ef
<unknown> 0x000000010b23d667
<unknown> 0x000000010b23d514
<unknown> 0x000000010a8a17e9
$s8NetCloud6iOSAppV5$mainyyFZ iOSApp.swift:3
main iOSApp.swift:0
start_sim 0x00000001061782bf
start 0x000000010f87141f
Priyanshu Jain
09/04/2023, 2:43 PMAlexander Maryanovsky
09/04/2023, 4:23 PMAlexander Maryanovsky
09/04/2023, 4:24 PMPriyanshu Jain
09/04/2023, 4:27 PMAngga Ardinata
10/17/2023, 4:20 AMCarlos Monzon
11/25/2023, 8:14 AM