mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

Transparency in raster overlays is not supported

Open cammace opened this issue 10 years ago • 28 comments

Using the same source and layer settings in this GL JS example but getting a black tile background. Here's what it looks like on Android:

ezgif com-video-to-gif 1

cc: @ivovandongen

cammace avatar Aug 03 '16 17:08 cammace

The black borders should be transparent, but the raster image format we’re using (JPG) does not support transparency, which is a known issue that exists in every gl-native-based SDK. The solution will be to serve a raster format that allows for transparency and then add support for that format here in core.

  • JPG is efficient (both in size and decode time) but does not support an alpha channel.
  • PNG does support alpha, but is not size efficient.
  • WebP is theoretically efficient and does support alpha, but our efforts to implement support in core have shown that it is quite slow to decode. See https://github.com/mapbox/mapbox-gl-native/issues/3572.

Indeed, this is a wider platform problem: the GL-JS example you linked to is broken in the same way in Safari (because there is no WebP support and we serve that browser JPGs):

screen shot 2016-08-03 at 2 13 25 pm

You’re probably using Chrome, which Mapbox detects and serves WebP raster tiles.

friedbunny avatar Aug 03 '16 21:08 friedbunny

WebP is theoretically efficient and does support alpha, but our efforts to implement support in core have shown that it is quite slow to decode. See #3572.

Is there more detail about "quite slow to decode" somewhere? I don't see any reference to performance issues in #3572.

jfirebaugh avatar Aug 22 '16 17:08 jfirebaugh

Is there more detail about "quite slow to decode" somewhere? I don't see any reference to performance issues in #3572.

@jfirebaugh It looks like @brunoabinader and @kkaefer came to that conclusion elsewhere while working on Qt, which (last I heard), resulted in us yanking WebP decoding from that platform.

friedbunny avatar Aug 22 '16 17:08 friedbunny

We were evaluating JPEG vs. WebP decoding speeds and many platforms (like iOS) have highly optimized JPEG decoders that take advantage of hardware features for FFT et al; WebP doesn't have that sort of optimization on those platforms. That being said, we should not remove WebP support because there are valid uses cases for it, despite it being slower to decode (~2-3× in some cases).

kkaefer avatar Aug 23 '16 09:08 kkaefer

Currently in memory caching is disabled for Raster sources in native. Enabling it might help with performance since it would avoid re decoding and re uploading the texture to Gpu every time the tile goes out and re appears in view port.

mb12 avatar Aug 23 '16 15:08 mb12

Pinging here. Friend reported this issue to me just recently. Fix on the horizon?

mikelmaron avatar Nov 18 '16 14:11 mikelmaron

Some solution for android, How to enable cache Raster in sdk Android captura de pantalla de 2016-11-25 12-04-33

edgarmacas avatar Nov 25 '16 17:11 edgarmacas

Noting here that raster caching was enabled in https://github.com/mapbox/mapbox-gl-native/pull/7091

kkaefer avatar Nov 29 '16 13:11 kkaefer

We're also looking forward to a fix.

GL JS version works perfectly fine: gl-web

Android and iOS however do not: gl-android

mmuelder avatar Mar 29 '17 09:03 mmuelder

GL JS version works perfectly fine

@mmuelder See https://github.com/mapbox/mapbox-gl-native/issues/5856#issuecomment-237379739 — browser support for semi-transparent tiles (via WebP) is currently limited to Chrome.

friedbunny avatar Apr 05 '17 20:04 friedbunny

I am having the same problem in my application. I already tried to create a tileset with the vector type, but the image quality was very poor in the smartphone. Has anyone managed to find a solution to this? If anyone can help, I would appreciate it.

phfeitosaa avatar May 14 '17 15:05 phfeitosaa

Is there another way to load a raster in mapbox for ios/android? I can't have these black borders.

robotjosh avatar Jun 14 '17 18:06 robotjosh

Is there any solution coming on horizon or this feature won't work on iOS at all?

kuchmiyalex avatar Aug 07 '17 06:08 kuchmiyalex

I don't think they plan on fixing this soon. The workaround is to load these geotiff into map box as a resource and add a line of code to load that resource into the map box interface.

-Josh

On Mon, Aug 7, 2017 at 1:57 AM, kuchmiyalex [email protected] wrote:

Is there any solution coming on horizon or this feature won't work on iOS at all?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mapbox/mapbox-gl-native/issues/5856#issuecomment-320584282, or mute the thread https://github.com/notifications/unsubscribe-auth/ABM7hg01LEJ5Ff9xwJgkDnccd0sHFkLcks5sVrVagaJpZM4Jb5N6 .

robotjosh avatar Aug 07 '17 13:08 robotjosh

@robotjosh Can you help me get this working? I'm adding geotiff into Mapbox Studio as a tileset, then adding it in a new layer in new style. Then using new style in iOS demo app. Got the same black background issue anyways. Is that approach you meant?

kuchmiyalex avatar Aug 07 '17 14:08 kuchmiyalex

@kuchmiyalex - in case your image(s) are not very large, you could use the 'Image' source type that was added in #1350. While it is mostly complete, it will not be available until the next major SDK release for iOS/Android.

asheemmamoowala avatar Aug 07 '17 18:08 asheemmamoowala

Hi there, is there any update on this issue yet?

warrenhharding avatar Nov 11 '17 07:11 warrenhharding

No but the workaround is simple enough.

On Sat, Nov 11, 2017 at 1:37 AM, Warren [email protected] wrote:

Hi there, is there any update on this issue yet?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mapbox/mapbox-gl-native/issues/5856#issuecomment-343647155, or mute the thread https://github.com/notifications/unsubscribe-auth/ABM7hp1A-leWTrGZvx7Rni3rGZbVFgO-ks5s1U67gaJpZM4Jb5N6 .

robotjosh avatar Nov 11 '17 19:11 robotjosh

Hi, just wondering if this issue has been resolved. If so how was it done?

baptistae avatar Oct 31 '18 03:10 baptistae

Hi, we are having the same issue :(

khannah avatar Nov 27 '18 21:11 khannah