Skip to content

Refact DebugAntilog null-safety for ios#97

Merged
AAkira merged 3 commits into
AAkira:masterfrom
ColaGom:refact-ios-null-safety
Apr 6, 2022
Merged

Refact DebugAntilog null-safety for ios#97
AAkira merged 3 commits into
AAkira:masterfrom
ColaGom:refact-ios-null-safety

Conversation

@ColaGom
Copy link
Copy Markdown
Contributor

@ColaGom ColaGom commented Mar 18, 2022

Environment

  • Apple M1 + xcode with rosetta
  • Apple intel + xcode
  • iOS 15.2 iPhone 11 simulator

Snippets

common module

fun initKoin() { ... Napier.d("initialized koin") }

AppDelegate

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    ...
    NapierProxyKt.debugBuild()
    ...
    KoinKt.initKoin()

Print Symbols

0 null
1 null
2 null
3 null
4 null
5 null
6 null
7 null
8 null <<- is null
9 null
10 null
11 null
12  UIKitCore                           0x00000001227f5f2f -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 216
13  UIKitCore                           0x00000001227f7b9f -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 4115
14  UIKitCore                           0x00000001227fd50e -[UIApplication _runWithMainScene:transitionContext:completion:] + 1221
15  UIKitCore                           0x0000000121d79c7a -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122
16  UIKitCore                           0x00000001223661c6 _UIScenePerformActionsWithLifecycleActionMask + 88
17  UIKitCore                           0x0000000121d7a771 __101-[_UISceneLifecycleMultiplexer

Desc

  • No problem with the new install. but, if re-install(build) in xcode after change code then throw NullPointerException.
  • I check NSThread.callStackSymbols, it shown 'null' value.

Solution

  • Antilog.performTag null-safety
  • I don't know why symbol value is null 😢

@ColaGom ColaGom changed the title Refact ios null safety Refact DebugAntilog null-safety for ios Mar 18, 2022
val target = symbols[CALL_STACK_INDEX] as? String

return if (target != null) createStackElementTag(target)
else tag
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I think braces are more appropriate.

https://developer.android.com/kotlin/style-guide#braces

return if (target != null) {
    createStackElementTag(target)
} else {
    tag
}

or

return (symbols[CALL_STACK_INDEX] as? String)?.let {
    createStackElementTag(it)
} ?: tag

@AAkira
Copy link
Copy Markdown
Owner

AAkira commented Apr 5, 2022

Thank you!
I know it is difficult.
But I'd be glad to know how to reproduce it if possible.

@ColaGom
Copy link
Copy Markdown
Contributor Author

ColaGom commented Apr 6, 2022

@AAkira thks for review 😄

More detail about reproduce step as below

Environment

Apple M1 + xcode with rosetta, Monterey 12.3
Apple intel + xcode, Monterey 12.3
iOS 15.2 iPhone 11 simulator

Reproduce step

  1. First run ios-app in xcode is no issue.
  2. Re-run app occurs NPE after fixing some code(swift)
    • If delete app and run it, issue does not occur.

@AAkira
Copy link
Copy Markdown
Owner

AAkira commented Apr 6, 2022

Thank you!

I don't have an M1 Mac right now, I will try it when I get it!

@AAkira AAkira merged commit 910917c into AAkira:master Apr 6, 2022
@AAkira AAkira mentioned this pull request Apr 6, 2022
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.

2 participants