software-mansion / radon-ide

VSCode extension that turns your editor into a fully fledged IDE for React Native and Expo.
https://ide.swmansion.com
Other
998 stars 35 forks source link

[Android] Add native logs #734

Closed maciekstosio closed 4 days ago

maciekstosio commented 1 week ago

The motivation of this PR is to pass native logs to Radon IDE. Currently, if the app crashes on the native side developer needs to open Android Studio anyway.

How it's done?

Changed during review:

Why like this? We don't want to pass all adb logcat logs, as those are enormous. I didn't find a way to filter logs by packageId (except filtering them with regex), so the most reliable way seems to be to filter them by PID.
Now, suppose the app crashes at the very beginning (for example, during MainApplication.onCreate()). In that case, we have no way of getting PID before (because the process is not created yet) and after (the process is already killed). To solve this case, for a short period of time, we go through all logs with regex to look for app start

2024-11-15 14:51:24.154 574-606 ActivityManager system_server I Start proc 4474:com.reactnative76/u0a198 for next-top-activity {com.reactnative76/com.reactnative76.MainActivity}

and extract pid. Then we kill this process and spawn one that is properly filtered (with history, so the logs that came up during app start are there too).

Remarks:

How Has This Been Tested:

Normal

Crash on startup

Demo:

vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radon-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 9:37am