Android maps black screen on Nexus 7

I’m getting reports from beta testers using new nexus 7’s that the screen is turning black (and some intermittent flashing) running with the latest daily builds.

I did a test with the mapView sample code on a nexus 7 (added a textfield to be displayed as well, and sure enough, it did it with that code as well.

After studying the adb logcat, I noticed an error message shortly after the map is activated in the app:

=====================
D/WebKit ( 9448): ERROR:
D/WebKit ( 9448): SQLite database failed to load from /GeolocationPermissions.d
b
D/WebKit ( 9448): Cause - unable to open database file
D/WebKit ( 9448):
D/WebKit ( 9448): external/webkit/Source/WebCore/platform/sql/SQLiteDatabase.cp
p(71) : bool WebCore::SQLiteDatabase::open(const WTF::String&, bool)
V/chromium( 9448): external/chromium/net/base/bandwidth_metrics.h:96: [1014/1905

After snooping around on the internet, it appears there were some permission changes that occurred with the release of JellyBean:

=====================
public abstract void setAllowFileAccessFromFileURLs (boolean flag)
Since: API Level 16

Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs. To enable the most restrictive, and therefore secure policy, this setting should be disabled. Note that the value of this setting is ignored if the value of getAllowUniversalAccessFromFileURLs() is true.

The default value is true for API level ICE_CREAM_SANDWICH_MR1 and below, and false for API level JELLY_BEAN and above.
Parameters
flag whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs

I really don’t know if this is causing my maps to go black screen on these new nexus 7 devices, but I’ve been trying to find a workaround for hours, and ran across this info.

If this worked on the Nexus 7 (and the GPS shut off on app suspend) — I’d be in business on the android!! Any help, Corona Labs? [import]uid: 79933 topic_id: 31956 reply_id: 331956[/import]

I’ve tested our sample app “Interface/MapView” on our Nexus 7 and have not seen this black screen issue. Can you try this same sample app on your Nexus 7 to see if you can reproduce it please?

Now, if only your native fields are turning black (ie: MapView and TextFields) but the rest is rendering okay, then that means we’re running into a conflict between our OpenGL view and Android’s hardware accelerated native fields. This used to be a problem with Corona on Android 4.0.3 and newer OS versions (which are hardware accelerated by default), but we be believed we solved all of those issues months ago.

I also have a quick work-around for you. If you set the [lua]alpha[/lua] property of your map view to something less than one, say 0.98, then that would force Corona to disable hardware acceleration on the map view and prevent this hardware acceleration conflict from occurring. That alpha value will be high enough that it would still appear opaque. The downside of this work-around is that scrolling will be noticeably slower. [import]uid: 32256 topic_id: 31956 reply_id: 127513[/import]

Thanks for the tip – But it didn’t solve my black screen issue… I’ll post more data on what’s going on later tonight… But I have a tip for you on the mapView bug in your Queue:

17645 Map view shows a thick white line on the right side on Galaxy SIII and Kindle Fire HD

Along with the mapview bug on my nexus 7 / black screen, I have this bug on a galaxy S3 as well…

Here’s the tip to help you make quick work of it…

The problem isn’t just a white line on the right side – It’s a buffering issue that you can clearly demonstrate with code… One of my mapviews is about 400 wide, and displayed with a virtual screen width of 640, the white line is much larger than a few pixels…

After playing around with the position of my mapview on screen, if it is displayed flsuh against the left border of the screen - the whole map is there - no white line…

If I position the map on the right edge of the screen, most of the map (right side) is covered in white – its not a line its a giant white rectangle… Moving the mapview left to right on the screen causes the white portion to grow or shink proportionally.

Hopefully that’ll help you out in tracking it down (maybe a bum x coord used during buffering). [import]uid: 79933 topic_id: 31956 reply_id: 127518[/import]

OK, this code shows the two different problems (the s3 problem, and nexus 7 problem) we are having. It’s a slightly modified version of the mapView example in the docs:

-- Create a native MapView (requires XCode Simulator build or device build)  
-- You can create multiple maps, if you like...  
--  
myMap = native.newMapView( 0, 0, 300, 200 )  
myMap.mapType = "standard" -- other mapType options are "satellite" or "hybrid"  
  
-- The MapView is just another Corona display object, and can be moved or rotated, etc.  
myMap.x = display.contentWidth / 2  
myMap.y = display.contentHeight / 2  
  
-- Initialize map to a real location, since default location (0,0) is not very interesting  
myMap:setCenter( 37.331692, -122.030456 )  
  
local function callMap()  
 -- Fetch the user's current location  
 -- Note: in XCode Simulator, the current location defaults to Apple headquarters in Cupertino, CA  
 local currentLocation = myMap:getUserLocation()  
 if currentLocation then  
 -- Move map so that current location is at the center  
 local currentLatitude = currentLocation.latitude  
 local currentLongitude = currentLocation.longitude  
 myMap:setCenter( currentLatitude, currentLongitude, true )  
  
 end  
end  
  
 -- Show a little text... mapView will overdraw it on Nexus 7 / Jelly Bean  
 local Title = display.newRetinaText( "Corona S3 / Nexus 7 Maptest", 10, 120, native.systemFont, 30 , { 255, 255, 255, 255 })   
 Title:setReferencePoint(display.CenterLeftReferencePoint)   
 Title:setTextColor( 255, 255, 255, 255 )   
 Title:setTextColor(255,255,255)  
  
timer.performWithDelay( 1000, callMap ) -- get current location after 1 second  

On the s3, part of the map is white, which changes based on the x coord of the map (left is better, right is more white).

On the nexus 7, scrolling around in the mapview causes a black rectangle to engulf the rest of the screen, covering over the text field… [import]uid: 79933 topic_id: 31956 reply_id: 127523[/import]

Thanks for the info about that white-bar/buffering issue. I thought it might be something like that, because I know for a fact that scrollbars are disabled. I’m also thinking that DPI is a factor. [import]uid: 32256 topic_id: 31956 reply_id: 127524[/import]

OK, looks like I verified your patch / workaround for the nexus 7 problem I am having… (Android 4.1.2)

Simply adding the code (you suggested above) causes the maps to work well again:

 if( utils.isAndroid == true) then   
 print( " --- SYSINFO == ", system.getInfo("platformVersion") )  
 if( system.getInfo("platformVersion") \> "4.1" ) then -- nexus 7 / Jelly Bean hardware bug workaround  
 mojoData.\_mapView.alpha = 0.99  
 end  

Not a fan of losing hardware accell for all future versions of android maps, but it gets me through beta at least. Thanks Joshua, and gods speed fixing the SIII bug and turning off the GPS on suspend!!!

Note: this fix does NOT work on my S III test case – which is android 4.0.4, instead, it makes the entire mapview turn white (instead of just a section).
[import]uid: 79933 topic_id: 31956 reply_id: 127528[/import]

I’ve tested our sample app “Interface/MapView” on our Nexus 7 and have not seen this black screen issue. Can you try this same sample app on your Nexus 7 to see if you can reproduce it please?

Now, if only your native fields are turning black (ie: MapView and TextFields) but the rest is rendering okay, then that means we’re running into a conflict between our OpenGL view and Android’s hardware accelerated native fields. This used to be a problem with Corona on Android 4.0.3 and newer OS versions (which are hardware accelerated by default), but we be believed we solved all of those issues months ago.

I also have a quick work-around for you. If you set the [lua]alpha[/lua] property of your map view to something less than one, say 0.98, then that would force Corona to disable hardware acceleration on the map view and prevent this hardware acceleration conflict from occurring. That alpha value will be high enough that it would still appear opaque. The downside of this work-around is that scrolling will be noticeably slower. [import]uid: 32256 topic_id: 31956 reply_id: 127513[/import]

Thanks for the tip – But it didn’t solve my black screen issue… I’ll post more data on what’s going on later tonight… But I have a tip for you on the mapView bug in your Queue:

17645 Map view shows a thick white line on the right side on Galaxy SIII and Kindle Fire HD

Along with the mapview bug on my nexus 7 / black screen, I have this bug on a galaxy S3 as well…

Here’s the tip to help you make quick work of it…

The problem isn’t just a white line on the right side – It’s a buffering issue that you can clearly demonstrate with code… One of my mapviews is about 400 wide, and displayed with a virtual screen width of 640, the white line is much larger than a few pixels…

After playing around with the position of my mapview on screen, if it is displayed flsuh against the left border of the screen - the whole map is there - no white line…

If I position the map on the right edge of the screen, most of the map (right side) is covered in white – its not a line its a giant white rectangle… Moving the mapview left to right on the screen causes the white portion to grow or shink proportionally.

Hopefully that’ll help you out in tracking it down (maybe a bum x coord used during buffering). [import]uid: 79933 topic_id: 31956 reply_id: 127518[/import]

OK, this code shows the two different problems (the s3 problem, and nexus 7 problem) we are having. It’s a slightly modified version of the mapView example in the docs:

-- Create a native MapView (requires XCode Simulator build or device build)  
-- You can create multiple maps, if you like...  
--  
myMap = native.newMapView( 0, 0, 300, 200 )  
myMap.mapType = "standard" -- other mapType options are "satellite" or "hybrid"  
  
-- The MapView is just another Corona display object, and can be moved or rotated, etc.  
myMap.x = display.contentWidth / 2  
myMap.y = display.contentHeight / 2  
  
-- Initialize map to a real location, since default location (0,0) is not very interesting  
myMap:setCenter( 37.331692, -122.030456 )  
  
local function callMap()  
 -- Fetch the user's current location  
 -- Note: in XCode Simulator, the current location defaults to Apple headquarters in Cupertino, CA  
 local currentLocation = myMap:getUserLocation()  
 if currentLocation then  
 -- Move map so that current location is at the center  
 local currentLatitude = currentLocation.latitude  
 local currentLongitude = currentLocation.longitude  
 myMap:setCenter( currentLatitude, currentLongitude, true )  
  
 end  
end  
  
 -- Show a little text... mapView will overdraw it on Nexus 7 / Jelly Bean  
 local Title = display.newRetinaText( "Corona S3 / Nexus 7 Maptest", 10, 120, native.systemFont, 30 , { 255, 255, 255, 255 })   
 Title:setReferencePoint(display.CenterLeftReferencePoint)   
 Title:setTextColor( 255, 255, 255, 255 )   
 Title:setTextColor(255,255,255)  
  
timer.performWithDelay( 1000, callMap ) -- get current location after 1 second  

On the s3, part of the map is white, which changes based on the x coord of the map (left is better, right is more white).

On the nexus 7, scrolling around in the mapview causes a black rectangle to engulf the rest of the screen, covering over the text field… [import]uid: 79933 topic_id: 31956 reply_id: 127523[/import]

Thanks for the info about that white-bar/buffering issue. I thought it might be something like that, because I know for a fact that scrollbars are disabled. I’m also thinking that DPI is a factor. [import]uid: 32256 topic_id: 31956 reply_id: 127524[/import]

OK, looks like I verified your patch / workaround for the nexus 7 problem I am having… (Android 4.1.2)

Simply adding the code (you suggested above) causes the maps to work well again:

 if( utils.isAndroid == true) then   
 print( " --- SYSINFO == ", system.getInfo("platformVersion") )  
 if( system.getInfo("platformVersion") \> "4.1" ) then -- nexus 7 / Jelly Bean hardware bug workaround  
 mojoData.\_mapView.alpha = 0.99  
 end  

Not a fan of losing hardware accell for all future versions of android maps, but it gets me through beta at least. Thanks Joshua, and gods speed fixing the SIII bug and turning off the GPS on suspend!!!

Note: this fix does NOT work on my S III test case – which is android 4.0.4, instead, it makes the entire mapview turn white (instead of just a section).
[import]uid: 79933 topic_id: 31956 reply_id: 127528[/import]