WhirlyGlobe icon indicating copy to clipboard operation
WhirlyGlobe copied to clipboard

[Android] Specifying grid shift file for CoordSystem results in rendering errors

Open drhaynes opened this issue 9 years ago • 9 comments

When creating a CoordSystem using a proj4 string and a grid shift file (provided with the nadgrids parameter), the tiles and markers are rendered incorrectly:

screenshot 2016-02-23 11 42 13

Furthermore, after a moment of interaction with the map, the rendering freezes and the app becomes completely unresponsive.

Log output below:

02-23 11:34:32.998 16921-16921/? I/art: Late-enabling -Xcheck:jni
02-23 11:34:33.212 16921-16941/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-23 11:34:33.221 16921-16921/? D/Atlas: Validating map...
02-23 11:34:33.233 16921-16921/? I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2f1cd402 time:13705446
02-23 11:34:33.265 16921-16941/? I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 01/15/15, ab0075f, Id3510ff6dc
02-23 11:34:33.266 16921-16941/? I/OpenGLRenderer: Initialized EGL, version 1.4
02-23 11:34:33.289 16921-16941/? D/OpenGLRenderer: Enabling debug mode 0
02-23 11:34:33.774 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.800 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.801 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.845 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.848 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.853 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.889 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.891 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.892 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.925 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.929 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:33.936 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.187 16921-16973/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.187 16921-16972/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.190 16921-16968/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.193 16921-16966/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.195 16921-16967/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.265 16921-16973/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.266 16921-16966/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.269 16921-16985/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.276 16921-16968/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.280 16921-16972/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.333 16921-16967/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:34:34.335 16921-16973/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.561 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.564 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.568 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.571 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.575 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.578 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.581 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.590 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.592 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.594 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.595 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.598 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.753 16921-18853/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.762 16921-18858/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.775 16921-18856/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.777 16921-18855/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.786 16921-18854/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.834 16921-18853/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.837 16921-18863/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.844 16921-18858/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.847 16921-18856/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.848 16921-18855/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.869 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.871 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.894 16921-18853/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.899 16921-18854/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.915 16921-18856/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.928 16921-18855/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.971 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.972 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.974 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.977 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.978 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.979 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:19.980 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.019 16921-18858/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.020 16921-18854/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.031 16921-18856/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.033 16921-18855/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.035 16921-18853/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.077 16921-18858/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.081 16921-18863/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.092 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.095 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.100 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.143 16921-18858/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.161 16921-18853/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.163 16921-18863/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.230 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.232 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.243 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.245 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.261 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.264 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.290 16921-18863/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.301 16921-18853/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.306 16921-18858/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.308 16921-18855/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.324 16921-18856/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.350 16921-18854/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.483 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.485 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.487 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.543 16921-18854/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.545 16921-18856/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.547 16921-18855/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.680 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.682 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.761 16921-18853/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.774 16921-18854/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.779 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.782 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.783 16921-16939/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.828 16921-16940/uk.os.maply E/Parcel: dup() failed in Parcel::read, i is 0, fds[i] is -1, fd_count is 1, error: Too many open files
02-23 11:36:20.831 16921-18858/uk.os.maply W/art: Large object allocation failed: ashmem_create_region failed for 'large object space allocation': Too many open files
02-23 11:36:20.832 16921-16940/uk.os.maply W/Adreno-GSL: <gsl_ldd_control:427>: ioctl fd 28 code 0xc0140933 (IOCTL_KGSL_TIMESTAMP_EVENT) failed: errno 22 Invalid argument
02-23 11:36:20.832 16921-16940/uk.os.maply W/Adreno-GSL: <ioctl_kgsl_syncobj_create:2103>: (1d, 6, 16098) fail 22 Invalid argument
02-23 11:36:20.832 16921-16940/uk.os.maply W/Adreno-EGLSUB: <SwapBuffers:1334>: gsl_device_3d_add_fence_event failed
02-23 11:36:20.832 16921-16940/uk.os.maply W/Adreno-EGL: <qeglDrvAPI_eglSwapBuffers:3788>: EGL_BAD_SURFACE
02-23 11:36:20.864 16921-18858/uk.os.maply I/art: Alloc sticky concurrent mark sweep GC freed 1661(199KB) AllocSpace objects, 7(112KB) LOS objects, 12% free, 16MB/18MB, paused 3.662ms total 21.026ms
02-23 11:36:20.880 16921-18854/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.883 16921-18853/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.893 16921-16940/uk.os.maply W/Adreno-EGLSUB: <DequeueBuffer:721>: dequeue native buffer fail: Unknown error 2147483646, buffer=0x0, handle=0x0
02-23 11:36:20.893 16921-16940/uk.os.maply W/Adreno-EGL: <qeglDrvAPI_eglSwapBuffers:3699>: EGL_BAD_SURFACE
02-23 11:36:20.894 16921-16940/uk.os.maply W/GLThread: eglSwapBuffers failed: EGL_BAD_SURFACE
02-23 11:36:20.904 16921-18855/uk.os.maply E/Maply: Failed to fetch remote tile 4: (5,9)
02-23 11:36:20.916 16921-18856/uk.os.maply W/art: Large object allocation failed: ashmem_create_region failed for 'large object space allocation': Too many open files
02-23 11:36:20.937 16921-18863/uk.os.maply D/skia: --- SkImageDecoder::Factory returned null
02-23 11:36:20.937 16921-18863/uk.os.maply E/Maply: Failed to fetch remote tile 4: (3,3)
02-23 11:36:20.962 16921-18856/uk.os.maply I/art: Alloc partial concurrent mark sweep GC freed 9675(535KB) AllocSpace objects, 20(4MB) LOS objects, 40% free, 12MB/20MB, paused 2.563ms total 43.182ms
02-23 11:36:20.963 16921-18856/uk.os.maply W/art: Large object allocation failed: ashmem_create_region failed for 'large object space allocation': Too many open files

drhaynes avatar Feb 23 '16 11:02 drhaynes

I've duplicated this. It looks like something in the projection is causing the the layer to go nuts. Probably something related to the extents.

I'll try to get this sorted out shortly. In the mean time, it does work without the shift file.

mousebird avatar Feb 25 '16 02:02 mousebird

The problem seems to be points outside the grid shift file. For whatever reason on Android the conversion fails outside that area.

The fix seems to be to provide a null grid shift file that'll work over the rest of the world. The one in the latest version of proj.4 doesn't seem to load correctly.

Do you have a null grid shift file lying around that you know works?

mousebird avatar Feb 25 '16 20:02 mousebird

Looking into it, should be as simple as using file null.lla with the following contents:

Null transform for whole world
   3   3   1  -180.00000   180.00000   -90.00000   90.00000
0: 0 0 0 0 0 0 
1: 0 0 0 0 0 0 
2: 0 0 0 0 0 0 

I wonder if it's a proj issue that is preventing this from being loaded on Android. Presumably you specified the nadgrids by listing both ostn02 and 'null' in the proj4 string.

Will try this our end and report back.

drhaynes avatar Feb 29 '16 14:02 drhaynes

I'll wait to hear back, but I suspect I'll need to upgrade my version of Proj.4 to accept the new null.lla file.

mousebird avatar Feb 29 '16 15:02 mousebird

Indeed, proj crashes when trying to load the above file.

The latest (4.9.2) release of https://github.com/OSGeo/proj.4 does not contain the iOS grid shift file loading fix, but the master branch does as per: https://github.com/OSGeo/proj.4/pull/348

drhaynes avatar Mar 01 '16 10:03 drhaynes

Well that's interesting. Okay, I'll need to upgrade proj.4. This'll take a few days.

But in the meantime, if you need to debug you can always drop the grid file.

mousebird avatar Mar 01 '16 15:03 mousebird

Thanks. Any progress on the upgrade?

drhaynes avatar Mar 09 '16 10:03 drhaynes

Today, I think.

mousebird avatar Mar 09 '16 15:03 mousebird

I spent a few hours on it yesterday.

I've upgraded the version of proj.4 and that's working fine on iOS, but it does exactly the same thing on Android. I think there may be a low level bug in proj.4 on Android.

So I'll need another round of debugging inside proj.4 to see what's really going on. Probably another few days.

mousebird avatar Mar 10 '16 18:03 mousebird