[jira] [Commented] (CB-6230) InAppBrowser closes after opening, instead of before
[ https://issues.apache.org/jira/browse/CB-6230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14152487#comment-14152487 ] Jacob Weber commented on CB-6230: - Sorry for the late response. My goal is this: * open an in-app browser * at some point, programmatically load a new URL into this browser Because of CB-6228, I can't just call window.open again to load the new URL. So this issue was based on my attempt to close the first window, then open a new one. To do that, I need to know when the first window is closed. Since calling close() before open() isn't guaranteed to work, because they're asynchronous, I tried waiting for the "exit" event: {code} onDeviceReady: function() { document.addEventListener('click', function() { // first open a window window.myWindow = window.open('http://www.google.com', "_blank"); window.myWindow.addEventListener('exit', function() { window.open('http://www.apple.com', "_blank"); }); // then in 5 seconds, close it setTimeout(function() { window.myWindow.close(); }, 5000); }); }, {code} When I run this and tap the page, the Google window opens. Five seconds later, I expect it to close, and the Apple window to open. But instead, after some flickering, a window with a Google URL remains open, but now it's blank, and it can't be closed. Putting the second window.open inside a 100-ms setTimeout looks like it's working, so I guess that's a workaround. But this seems unreliable. (You can ignore my comment from 03/Jul -- the "exit" event is working for me now.) > InAppBrowser closes after opening, instead of before > > > Key: CB-6230 > URL: https://issues.apache.org/jira/browse/CB-6230 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin InAppBrowser >Affects Versions: 3.4.0, 3.5.0 > Environment: Android 4.3, Galaxy Nexus >Reporter: Jacob Weber >Assignee: Joe Bowser >Priority: Minor > > In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. > In www/js/index.js, make the following change: > {noformat} > onDeviceReady: function() { > app.receivedEvent('deviceready'); > document.addEventListener('click', function() { > if (window.myWindow) window.myWindow.close(); > window.myWindow = window.open('http://www.google.com', "_blank"); > }); > }, > {noformat} > Tap the page once, and a browser will appear. Close the browser. Then tap the > app again. This time the browser will appear for a split second, then close > right away. The close() call seems to be happening after the subsequent > open() call, instead of before it. > This was working in 3.3, with InAppBrowser 0.2.5. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (CB-6230) InAppBrowser closes after opening, instead of before
[ https://issues.apache.org/jira/browse/CB-6230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14141371#comment-14141371 ] Joe Bowser commented on CB-6230: I think there's something wrong with your example code w.r.t to how the execution of it will work after some recent refactors. If you're expecting the browser to close an old object before it opens, that's not guaranteed to happen. In fact, once you open an InAppBrowser window then close it, the myWindow object is still present. However, it's not guaranteed that close will work faster than open in this case. If you could explain what you're trying to do with this code, that may be better, because it's not clear here. This looks less like a problem with the way InAppBrowser works per-se, and more a problem with JS. > InAppBrowser closes after opening, instead of before > > > Key: CB-6230 > URL: https://issues.apache.org/jira/browse/CB-6230 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin InAppBrowser >Affects Versions: 3.4.0, 3.5.0 > Environment: Android 4.3, Galaxy Nexus >Reporter: Jacob Weber >Assignee: Joe Bowser > > In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. > In www/js/index.js, make the following change: > {noformat} > onDeviceReady: function() { > app.receivedEvent('deviceready'); > document.addEventListener('click', function() { > if (window.myWindow) window.myWindow.close(); > window.myWindow = window.open('http://www.google.com', "_blank"); > }); > }, > {noformat} > Tap the page once, and a browser will appear. Close the browser. Then tap the > app again. This time the browser will appear for a split second, then close > right away. The close() call seems to be happening after the subsequent > open() call, instead of before it. > This was working in 3.3, with InAppBrowser 0.2.5. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (CB-6230) InAppBrowser closes after opening, instead of before
[ https://issues.apache.org/jira/browse/CB-6230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14127746#comment-14127746 ] Jacob Weber commented on CB-6230: - Were you able to reproduce this? I don't want to get stuck on an old version of Cordova. > InAppBrowser closes after opening, instead of before > > > Key: CB-6230 > URL: https://issues.apache.org/jira/browse/CB-6230 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin InAppBrowser >Affects Versions: 3.4.0, 3.5.0 > Environment: Android 4.3, Galaxy Nexus >Reporter: Jacob Weber > > In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. > In www/js/index.js, make the following change: > {noformat} > onDeviceReady: function() { > app.receivedEvent('deviceready'); > document.addEventListener('click', function() { > if (window.myWindow) window.myWindow.close(); > window.myWindow = window.open('http://www.google.com', "_blank"); > }); > }, > {noformat} > Tap the page once, and a browser will appear. Close the browser. Then tap the > app again. This time the browser will appear for a split second, then close > right away. The close() call seems to be happening after the subsequent > open() call, instead of before it. > This was working in 3.3, with InAppBrowser 0.2.5. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (CB-6230) InAppBrowser closes after opening, instead of before
[ https://issues.apache.org/jira/browse/CB-6230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14051608#comment-14051608 ] Jacob Weber commented on CB-6230: - [~edewit] I tried that exact listener, but the "exit" even never gets fired. Also, when I'm seeing this problem in real life, it's not due to the async nature of the close() call. I'm calling close() several minutes before I try to call window.open() again. > InAppBrowser closes after opening, instead of before > > > Key: CB-6230 > URL: https://issues.apache.org/jira/browse/CB-6230 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin InAppBrowser >Affects Versions: 3.4.0, 3.5.0 >Reporter: Jacob Weber > > In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. > In www/js/index.js, make the following change: > {noformat} > onDeviceReady: function() { > app.receivedEvent('deviceready'); > document.addEventListener('click', function() { > if (window.myWindow) window.myWindow.close(); > window.myWindow = window.open('http://www.google.com', "_blank"); > }); > }, > {noformat} > Tap the page once, and a browser will appear. Close the browser. Then tap the > app again. This time the browser will appear for a split second, then close > right away. The close() call seems to be happening after the subsequent > open() call, instead of before it. > This was working in 3.3, with InAppBrowser 0.2.5. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6230) InAppBrowser closes after opening, instead of before
[ https://issues.apache.org/jira/browse/CB-6230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14051404#comment-14051404 ] Erik Jan de Wit commented on CB-6230: - It's because all of these functions are async, but there is an event that get's called when the close is done. So you could add a listener like this: {code} if (window.myWindow) { window.myWindow.addEventListener('exit', function() { window.myWindow = window.open('http://www.google.com', "_blank"); }); window.myWindow.close(); } else { window.myWindow = window.open('http://www.google.com', "_blank"); } {code} > InAppBrowser closes after opening, instead of before > > > Key: CB-6230 > URL: https://issues.apache.org/jira/browse/CB-6230 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin InAppBrowser >Affects Versions: 3.4.0, 3.5.0 >Reporter: Jacob Weber > > In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. > In www/js/index.js, make the following change: > {noformat} > onDeviceReady: function() { > app.receivedEvent('deviceready'); > document.addEventListener('click', function() { > if (window.myWindow) window.myWindow.close(); > window.myWindow = window.open('http://www.google.com', "_blank"); > }); > }, > {noformat} > Tap the page once, and a browser will appear. Close the browser. Then tap the > app again. This time the browser will appear for a split second, then close > right away. The close() call seems to be happening after the subsequent > open() call, instead of before it. > This was working in 3.3, with InAppBrowser 0.2.5. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6230) InAppBrowser closes after opening, instead of before
[ https://issues.apache.org/jira/browse/CB-6230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14049979#comment-14049979 ] Jacob Weber commented on CB-6230: - [~edewit] This is just a condensed example. In real usage, this happens whenever I want to open a browser, then later close it, and then later open another one. The close doesn't need to happen immediately before the open, like in this example. > InAppBrowser closes after opening, instead of before > > > Key: CB-6230 > URL: https://issues.apache.org/jira/browse/CB-6230 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin InAppBrowser >Affects Versions: 3.4.0, 3.5.0 >Reporter: Jacob Weber > > In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. > In www/js/index.js, make the following change: > {noformat} > onDeviceReady: function() { > app.receivedEvent('deviceready'); > document.addEventListener('click', function() { > if (window.myWindow) window.myWindow.close(); > window.myWindow = window.open('http://www.google.com', "_blank"); > }); > }, > {noformat} > Tap the page once, and a browser will appear. Close the browser. Then tap the > app again. This time the browser will appear for a split second, then close > right away. The close() call seems to be happening after the subsequent > open() call, instead of before it. > This was working in 3.3, with InAppBrowser 0.2.5. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6230) InAppBrowser closes after opening, instead of before
[ https://issues.apache.org/jira/browse/CB-6230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14049699#comment-14049699 ] Erik Jan de Wit commented on CB-6230: - Can't you remove the close call? > InAppBrowser closes after opening, instead of before > > > Key: CB-6230 > URL: https://issues.apache.org/jira/browse/CB-6230 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin InAppBrowser >Affects Versions: 3.4.0, 3.5.0 >Reporter: Jacob Weber > > In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. > In www/js/index.js, make the following change: > {noformat} > onDeviceReady: function() { > app.receivedEvent('deviceready'); > document.addEventListener('click', function() { > if (window.myWindow) window.myWindow.close(); > window.myWindow = window.open('http://www.google.com', "_blank"); > }); > }, > {noformat} > Tap the page once, and a browser will appear. Close the browser. Then tap the > app again. This time the browser will appear for a split second, then close > right away. The close() call seems to be happening after the subsequent > open() call, instead of before it. > This was working in 3.3, with InAppBrowser 0.2.5. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6230) InAppBrowser closes after opening, instead of before
[ https://issues.apache.org/jira/browse/CB-6230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14034121#comment-14034121 ] Jacob Weber commented on CB-6230: - Ping. > InAppBrowser closes after opening, instead of before > > > Key: CB-6230 > URL: https://issues.apache.org/jira/browse/CB-6230 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin InAppBrowser >Affects Versions: 3.4.0, 3.5.0 >Reporter: Jacob Weber > > In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. > In www/js/index.js, make the following change: > {noformat} > onDeviceReady: function() { > app.receivedEvent('deviceready'); > document.addEventListener('click', function() { > if (window.myWindow) window.myWindow.close(); > window.myWindow = window.open('http://www.google.com', "_blank"); > }); > }, > {noformat} > Tap the page once, and a browser will appear. Close the browser. Then tap the > app again. This time the browser will appear for a split second, then close > right away. The close() call seems to be happening after the subsequent > open() call, instead of before it. > This was working in 3.3, with InAppBrowser 0.2.5. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6230) InAppBrowser closes after opening, instead of before
[ https://issues.apache.org/jira/browse/CB-6230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14009876#comment-14009876 ] Jacob Weber commented on CB-6230: - Re-tested with Cordova 3.5 and InAppBrowser 0.4.0. This is still a bug. This has prevented me from upgrading from 3.3. > InAppBrowser closes after opening, instead of before > > > Key: CB-6230 > URL: https://issues.apache.org/jira/browse/CB-6230 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin InAppBrowser >Affects Versions: 3.4.0 >Reporter: Jacob Weber > > In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. > In www/js/index.js, make the following change: > {noformat} > onDeviceReady: function() { > app.receivedEvent('deviceready'); > document.addEventListener('click', function() { > if (window.myWindow) window.myWindow.close(); > window.myWindow = window.open('http://www.google.com', "_blank"); > }); > }, > {noformat} > Tap the page once, and a browser will appear. Close the browser. Then tap the > app again. This time the browser will appear for a split second, then close > right away. The close() call seems to be happening after the subsequent > open() call, instead of before it. > This was working in 3.3, with InAppBrowser 0.2.5. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (CB-6230) InAppBrowser closes after opening, instead of before
[ https://issues.apache.org/jira/browse/CB-6230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13973643#comment-13973643 ] Jacob Weber commented on CB-6230: - Were you able to reproduce this? Let me know if you need more info. > InAppBrowser closes after opening, instead of before > > > Key: CB-6230 > URL: https://issues.apache.org/jira/browse/CB-6230 > Project: Apache Cordova > Issue Type: Bug > Components: Android, Plugin InAppBrowser >Affects Versions: 3.4.0 >Reporter: Jacob Weber > > In Cordova 3.4, with InAppBrowser 0.3.3, create a new project using the CLI. > In www/js/index.js, make the following change: > {noformat} > onDeviceReady: function() { > app.receivedEvent('deviceready'); > document.addEventListener('click', function() { > if (window.myWindow) window.myWindow.close(); > window.myWindow = window.open('http://www.google.com', "_blank"); > }); > }, > {noformat} > Tap the page once, and a browser will appear. Close the browser. Then tap the > app again. This time the browser will appear for a split second, then close > right away. The close() call seems to be happening after the subsequent > open() call, instead of before it. > This was working in 3.3, with InAppBrowser 0.2.5. -- This message was sent by Atlassian JIRA (v6.2#6252)