Skip to content

Conversation

@YumeYuka
Copy link

@YumeYuka YumeYuka commented Sep 1, 2025

YumeYuka and others added 3 commits September 1, 2025 21:27
(cherry picked from commit 1f7374d)
(cherry picked from commit ae51089)
(cherry picked from commit 52eec80)
luyanci added a commit to luyanci/KernelSU that referenced this pull request Sep 7, 2025
Co-Authored-By: 梦璃酱 <[email protected]>
Co-Authored-By: 白彩恋 <[email protected]>
@Ylarod Ylarod requested a review from Copilot September 13, 2025 10:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes memory leaks in the WebUI component by properly cleaning up WebView resources and improving resource management. The changes focus on preventing memory leaks that can occur when WebView instances are not properly destroyed.

  • Replaced loadUrl() with evaluateJavascript() for better performance and security
  • Improved WebView cleanup in onDestroy() with proper resource disposal
  • Enhanced string building using buildString for better memory efficiency

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
WebViewInterface.kt Improved string building and replaced deprecated loadUrl() calls with evaluateJavascript()
WebUIActivity.kt Added proper WebView cleanup in onDestroy() and improved resource management

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

completableFuture.thenAccept { result ->
val emitExitCode =
"javascript: (function() { try { ${callbackFunc}.emit('exit', ${result.code}); } catch(e) { console.error(`emitExit error: \${e}`); } })();"
$$"(function() { try { $${callbackFunc}.emit('exit', $${result.code}); } catch(e) { console.error(`emitExit error: ${e}`); } })();"
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

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

Invalid string template syntax. The $$ prefix is not valid Kotlin syntax. This should use regular string interpolation with $ or raw strings.

Suggested change
$$"(function() { try { $${callbackFunc}.emit('exit', $${result.code}); } catch(e) { console.error(`emitExit error: ${e}`); } })();"
"""(function() { try { ${callbackFunc}.emit('exit', ${result.code}); } catch(e) { console.error(`emitExit error: ${'$'}{e}`); } })();"""

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +37
val moduleId = intent.getStringExtra("id") ?: finishAndRemoveTask().let { return }
val name = intent.getStringExtra("name") ?: finishAndRemoveTask().let { return }
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The .let { return } pattern is unclear and could be confusing. Consider using explicit null checks with early returns for better readability: if (moduleId == null) { finishAndRemoveTask(); return }

Suggested change
val moduleId = intent.getStringExtra("id") ?: finishAndRemoveTask().let { return }
val name = intent.getStringExtra("name") ?: finishAndRemoveTask().let { return }
val moduleId = intent.getStringExtra("id")
if (moduleId == null) {
finishAndRemoveTask()
return
}
val name = intent.getStringExtra("name")
if (name == null) {
finishAndRemoveTask()
return
}

Copilot uses AI. Check for mistakes.

private var rootShell: Shell? = null
private val rootShell by lazy { createRootShell(true) }
private var webView = null as WebView?
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

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

Using null as WebView? is redundant. Simply use private var webView: WebView? = null for cleaner code.

Suggested change
private var webView = null as WebView?
private var webView: WebView? = null

Copilot uses AI. Check for mistakes.
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