Commit 3a1a03d9 authored by dsq's avatar dsq

用于临时测试-不合入master

parent 3754154c
...@@ -29,13 +29,10 @@ kotlin { ...@@ -29,13 +29,10 @@ kotlin {
).forEach { iosTarget -> ).forEach { iosTarget ->
iosTarget.binaries.framework { iosTarget.binaries.framework {
baseName = "ComposeApp" baseName = "ComposeApp"
isStatic = true // 动态 framework:拖入 Xcode 后 Embed & Sign;静态需 -force_load,易与 *Stub 问题混淆。
} isStatic = false
iosTarget.compilations.getByName("main") {
compilerOptions.configure {
freeCompilerArgs.add("-Xbinary=sanitizer=address")
}
} }
// 勿在 iOS 启用 Address Sanitizer(仅 OHOS 需要)。否则产物含大量未解析 Konan *Stub,Xcode 链接失败。
} }
...@@ -228,4 +225,20 @@ arrayOf("debug", "release").forEach { type -> ...@@ -228,4 +225,20 @@ arrayOf("debug", "release").forEach { type ->
} }
} }
// 命令行打好 framework 后拖入 Xcode:产物在 composeApp/build/ios-drag-export/…
tasks.register<Sync>("syncComposeAppFrameworkIosArm64Release") {
group = "iOS"
description = "同步真机 arm64 Release 的 ComposeApp.framework 到 build/ios-drag-export/(供拖入 Xcode)"
dependsOn("linkReleaseFrameworkIosArm64")
from(layout.buildDirectory.dir("bin/iosArm64/releaseFramework/ComposeApp.framework"))
into(layout.buildDirectory.dir("ios-drag-export/arm64-release"))
}
tasks.register<Sync>("syncComposeAppFrameworkIosSimulatorArm64Release") {
group = "iOS"
description = "同步 Apple Silicon 模拟器 arm64 Release 的 ComposeApp.framework 到 build/ios-drag-export/(供拖入 Xcode)"
dependsOn("linkReleaseFrameworkIosSimulatorArm64")
from(layout.buildDirectory.dir("bin/iosSimulatorArm64/releaseFramework/ComposeApp.framework"))
into(layout.buildDirectory.dir("ios-drag-export/simulator-arm64-release"))
}
package com.dong.demo013
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.withFrameMillis
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
private fun perfPlatformTag(): String {
val n = "11111"
return when {
n.contains("iOS", ignoreCase = true) || n.contains("iPadOS", ignoreCase = true) -> "ios"
n.contains("Android", ignoreCase = true) -> "android"
else -> "harmony"
}
}
@Composable
internal fun Compose1500Text() {
val scrollState = rememberScrollState()
val platformTag = perfPlatformTag()
LaunchedEffect(Unit) {
// val enterTs = PerfLogger.get("scene_1500text_enter_click_ts") ?: nowMs()
//这里发送进入
os_signal_set("进入页面")
// 至少等到一帧真正调度后再记「首帧」,避免与点击同一时刻的伪首帧
withFrameMillis { }
//这里发送首帧
os_signal_set("进入首帧")
// 等布局给出可滚动高度后再滚到底,再等一帧记「完成」
while (scrollState.maxValue == 0) {
os_signal_set("一帧完成")
withFrameMillis { }
}
//这里发送开始滚动
os_signal_set("开始滚动")
scrollState.scrollTo(scrollState.maxValue)
withFrameMillis { }
//这里发送结束滚动
os_signal_set("结束滚动")
}
Column(
modifier =
Modifier.verticalScroll(scrollState).fillMaxWidth().semantics {
contentDescription = "包含 1500 个文本项目的性能测试列表"
},
horizontalAlignment = Alignment.CenterHorizontally
) {
repeat(1500) { index ->
Text(
text = "Compose1500Text Item #$index",
fontSize = 16.sp,
modifier =
Modifier.width(300.dp)
.height(50.dp)
.border(1.dp, Color.Gray)
.padding(10.dp)
.semantics { contentDescription = "文本项目 第 $index 号" }
)
}
}
}
...@@ -29,7 +29,7 @@ import kotlin.native.concurrent.ThreadLocal ...@@ -29,7 +29,7 @@ import kotlin.native.concurrent.ThreadLocal
@Composable @Composable
internal fun App() { internal fun App() {
LaunchedEffect(Unit){ LaunchedEffect(Unit) {
allBreakpoints() allBreakpoints()
} }
MaterialTheme { MaterialTheme {
...@@ -45,6 +45,7 @@ internal fun App() { ...@@ -45,6 +45,7 @@ internal fun App() {
} }
) )
} }
is Page.Detail -> { is Page.Detail -> {
DemoScreen(demo = p.demo, onBack = { page = Page.Home }) DemoScreen(demo = p.demo, onBack = { page = Page.Home })
} }
...@@ -60,10 +61,36 @@ internal fun HomeScreen( ...@@ -60,10 +61,36 @@ internal fun HomeScreen(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.padding(16.dp) .padding(16.dp)
.verticalScroll(rememberScrollState()) .verticalScroll(rememberScrollState()),
,
verticalArrangement = Arrangement.spacedBy(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp),
) { ) {
Card(
modifier = Modifier.fillMaxWidth(),
elevation = 8.dp,
shape = RoundedCornerShape(12.dp)
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
) {
Button(
onClick = {
os_signal_set("离开首页")
val debugDataDemo = ComponentDemo(
id = "to_1500",
title = "进入1500Text测试页面",
group = ComposeGroup.Foundation
)
onSelect(debugDataDemo)
},
modifier = Modifier.fillMaxWidth()
) {
}
}
}
// 第一个模块:debug页面 // 第一个模块:debug页面
Card( Card(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
...@@ -272,7 +299,7 @@ internal fun HomeScreen( ...@@ -272,7 +299,7 @@ internal fun HomeScreen(
verticalArrangement = Arrangement.spacedBy(8.dp) verticalArrangement = Arrangement.spacedBy(8.dp)
) { ) {
Button( Button(
onClick = { onClick = {
val logDemo = ComponentDemo( val logDemo = ComponentDemo(
id = "log_test_demo", id = "log_test_demo",
title = "日志测试演示(持续产生)", title = "日志测试演示(持续产生)",
...@@ -331,16 +358,18 @@ internal fun DemoScreen( ...@@ -331,16 +358,18 @@ internal fun DemoScreen(
) { ) {
Text("返回首页") Text("返回首页")
} }
// 根据 demo.id 显示对应的内容 // 根据 demo.id 显示对应的内容
when (demo.id) { when (demo.id) {
//日志 //日志
"log_test_demo" -> { "log_test_demo" -> {
HighLogDemo() HighLogDemo()
} }
"log_fault_demo" -> { "log_fault_demo" -> {
FaultLogDemo() FaultLogDemo()
} }
"log_over_demo" -> { "log_over_demo" -> {
NativeFaultDemo() NativeFaultDemo()
} }
...@@ -348,15 +377,23 @@ internal fun DemoScreen( ...@@ -348,15 +377,23 @@ internal fun DemoScreen(
"debug_test_demo" -> { "debug_test_demo" -> {
DebugTestDemo() DebugTestDemo()
} }
"debug_stepover_demo" -> { "debug_stepover_demo" -> {
DebugStepOverDemo() DebugStepOverDemo()
} }
"debug_stepinto_demo" -> { "debug_stepinto_demo" -> {
DebugStepIntoDemo() DebugStepIntoDemo()
} }
"debug_stepout_demo" -> { "debug_stepout_demo" -> {
DebugStepOutDemo() DebugStepOutDemo()
} }
"to_1500" -> {
Compose1500Text()
}
else -> { else -> {
Text( Text(
text = "暂未实现: ${demo.title}", text = "暂未实现: ${demo.title}",
......
...@@ -14,4 +14,8 @@ expect fun testArkTsToKotin(); ...@@ -14,4 +14,8 @@ expect fun testArkTsToKotin();
//稳定触发鸿蒙卡死 //稳定触发鸿蒙卡死
expect fun triggerANRByInfiniteLoop(); expect fun triggerANRByInfiniteLoop();
\ No newline at end of file
expect fun os_signal_set(type: String)
package com.dong.demo013 package com.dong.demo013
import platform.Foundation.NSNotificationCenter
actual fun pirntAllLevelHiLog() { actual fun pirntAllLevelHiLog() {
} }
...@@ -14,4 +16,12 @@ actual fun testArkTsToKotin() { ...@@ -14,4 +16,12 @@ actual fun testArkTsToKotin() {
} }
actual fun triggerANRByInfiniteLoop() { actual fun triggerANRByInfiniteLoop() {
}
actual fun os_signal_set(type: String) {
val notificationName = "set_os_signal"
val userInfo = null
NSNotificationCenter.defaultCenter().postNotificationName(notificationName,type)
} }
\ No newline at end of file
...@@ -23,7 +23,7 @@ composeMultiplatform = "1.9.2-0.2.0-04" ...@@ -23,7 +23,7 @@ composeMultiplatform = "1.9.2-0.2.0-04"
# Kotlin & testing # Kotlin & testing
junit = "4.13.2" junit = "4.13.2"
kotlin = "2.2.21-0.2.0-12" kotlin = "2.2.21-0.2.0-04"
kotlinx-coroutines = "1.10.2-0.2.0-02" kotlinx-coroutines = "1.10.2-0.2.0-02"
atomicFu = "0.31.0-0.2.0-03" atomicFu = "0.31.0-0.2.0-03"
......
...@@ -175,7 +175,7 @@ ...@@ -175,7 +175,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\n./gradlew :composeApp:embedAndSignAppleFrameworkForXcode\n"; shellScript = "if [ \"1\" = \"${SKIP_GRADLE_KOTLIN_EMBED:-}\" ]; then\n echo \"SKIP_GRADLE_KOTLIN_EMBED=1: 跳过 Gradle,请使用已拖入的 ComposeApp.framework(FRAMEWORK_SEARCH_PATHS 含 \\$(PROJECT_DIR)/Frameworks)\"\n exit 0\nfi\nif [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"注意: OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED=YES 会跳过 embed;若未手动更新 framework,链接会失败。可设 SKIP_GRADLE_KOTLIN_EMBED=1 明确表示只用拖入的 framework。\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\n./gradlew :composeApp:embedAndSignAppleFrameworkForXcode\n";
}; };
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */
...@@ -323,7 +323,8 @@ ...@@ -323,7 +323,8 @@
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)", "$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
"$(PROJECT_DIR)/Frameworks",
); );
INFOPLIST_FILE = iosApp/Info.plist; INFOPLIST_FILE = iosApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.3; IPHONEOS_DEPLOYMENT_TARGET = 15.3;
...@@ -334,7 +335,7 @@ ...@@ -334,7 +335,7 @@
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"$(inherited)", "$(inherited)",
"-framework", "-framework",
composeApp, "ComposeApp",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.eazytec.dong.testKmpIOS; PRODUCT_BUNDLE_IDENTIFIER = com.eazytec.dong.testKmpIOS;
PRODUCT_NAME = Demo; PRODUCT_NAME = Demo;
...@@ -355,7 +356,8 @@ ...@@ -355,7 +356,8 @@
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)", "$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
"$(PROJECT_DIR)/Frameworks",
); );
INFOPLIST_FILE = iosApp/Info.plist; INFOPLIST_FILE = iosApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.3; IPHONEOS_DEPLOYMENT_TARGET = 15.3;
...@@ -366,7 +368,7 @@ ...@@ -366,7 +368,7 @@
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"$(inherited)", "$(inherited)",
"-framework", "-framework",
composeApp, "ComposeApp",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.eazytec.dong.testKmpIOS; PRODUCT_BUNDLE_IDENTIFIER = com.eazytec.dong.testKmpIOS;
PRODUCT_NAME = Demo; PRODUCT_NAME = Demo;
......
...@@ -7,7 +7,19 @@ struct iOSApp: App { ...@@ -7,7 +7,19 @@ struct iOSApp: App {
var body: some Scene { var body: some Scene {
let test1:String="111"; let test1:String="111";
WindowGroup { WindowGroup {
ContentView() ContentView().onAppear(){
NotificationCenter.default.addObserver(
forName: NSNotification.Name("set_os_signal"),
object: nil,
queue: .main
) { note in
if let text = note.object as? String {
print("set_os_signal: \(text)")
}
}
}
.ignoresSafeArea() .ignoresSafeArea()
.background(Color.clear) // 确保整个背景透明 .background(Color.clear) // 确保整个背景透明
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment