-
-
Notifications
You must be signed in to change notification settings - Fork 95
fix(android): resolve WebViewDialog with webViewId and return result #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
crosslist-jonaslarsen
wants to merge
2
commits into
Cap-go:main
from
crosslist-jonaslarsen:fix/resolve-WebViewDialog-with-webViewId
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Cap-go/capacitor-inappbrowser
Length of output: 10943
🏁 Script executed:
Repository: Cap-go/capacitor-inappbrowser
Length of output: 2457
🏁 Script executed:
Repository: Cap-go/capacitor-inappbrowser
Length of output: 1077
🏁 Script executed:
Repository: Cap-go/capacitor-inappbrowser
Length of output: 1237
🌐 Web query:
Capacitor PluginCall resolve() called multiple times behavior💡 Result:
By default in Capacitor, a
PluginCall/CAPPluginCallis single-shot: once you callcall.resolve()orcall.reject()the bridge removes its bookkeeping for that callback, so laterresolve()calls won’t be delivered back to JS (and may just log/behave like a no-op). [1]If you intentionally need to send multiple results from one native call, you must mark the call as a callback/stream by setting
keepAlive(call.setKeepAlive(true)on Android /call.keepAlive = trueon iOS). WithkeepAlive = true,resolve()can be called repeatedly and each result is sent to JS. [1]Also, even with
keepAlive, you cannot receive multiple results via a normal JSPromise(await plugin.method()/.then(...)), because a promise resolves only once. You must use a callback-style method (or plugin events likenotifyListeners) to receive multiple updates. [2]Sources: [1] Saving/Persisting Plugin Calls (Capacitor docs) (capacitorjs.jp), [2] Ionic Forum: “Help with resolving call multiple times (Call keepAlive)” (forum.ionicframework.com)
Citations:
🏁 Script executed:
Repository: Cap-go/capacitor-inappbrowser
Length of output: 876
Fix correctly includes
instanceIdin the resolved result.The implementation properly creates a
JSObjectwith theidfield set toinstanceId, addressing the issue where JavaScript receivedundefinedfor thewebViewId.However, there is a logical issue: if both
isHidden()andisPresentAfterPageLoad()are true,presentWebView()will resolve at line 982, andonPageFinished()will attempt to resolve again at lines 2793/2808. While Capacitor's single-shotPluginCallprevents the second resolution from reaching JavaScript, this still represents flawed logic. Either:isHidden()andisPresentAfterPageLoad()are mutually exclusive through validation, or🤖 Prompt for AI Agents