Web popup fails to load until orientation change

My app launches a web popup when it first loads, and for a while I was banging my head against the wall trying to figure out how to get the local files in the web popup to load faster.

Then I realized that, if I change the device’s orientation right as the app is loading, the web popup loads almost instantly. It’s as though the initial showWebPopup gets stuck, but the one generated by an orientation change works.

Anyone have any ideas why this might be? Here’s the code:

[code]
– loadText function –

function loadText()
– create web popup
native.cancelWebPopup()
native.showWebPopup( url, 0, display.contentWidth, display.contentHeight, url, { hasBackground = true, baseUrl = system.ResourceDirectory, urlRequest = htmlData } )
end

– orientation change –

local function orientationChange()
loadText()
end
Runtime:addEventListener( “orientation”, orientationChange )
[/code] [import]uid: 61256 topic_id: 18159 reply_id: 318159[/import]

On alternative I’ve thought of is to programmatically trigger an orientation change event, but I’m not sure if that’s even possible. Suggestions? [import]uid: 61256 topic_id: 18159 reply_id: 69404[/import]

I’ve resolved the problem. Here’s the story:

For some reason the orientation event was being triggered by Corona on app load, and that was somehow causing the web popup to fail to load. I had to modify my code like this in order to prevent it:

-- loadText function --  
  
 local rotatable = "no"  
 function loadText()  
 -- enable rotation  
 rotatable = "yes"  
 -- create web popup  
 native.cancelWebPopup()  
 native.showWebPopup( 0, 0, display.contentWidth, display.contentHeight, url, { hasBackground = true, baseUrl = system.ResourceDirectory, urlRequest = htmlData } )  
 end  
  
-- orientation change --  
  
 local function orientationChange()  
 if (rotatable == "yes") then  
 loadText()  
 end  
 end   
 Runtime:addEventListener( "orientation", orientationChange )  
  
-- initial load --  
  
 local function initLoadText()  
 loadText()  
 end  
 initText = timer.performWithDelay( 1000, initLoadText, 1 )  

As you can see, I had to prevent orientation changes from registering until after the initial web popup had loaded, and I also needed to delay that initial load.

Clearly, there are some bugs at play here. I plan to submit a bug report. [import]uid: 61256 topic_id: 18159 reply_id: 69418[/import]