Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Cannot apply Layer FIlter with "in" or "!in" operator and more that 512 elements in Filter.SimpleStatement #6605

Closed
AlexeyIke opened this issue Oct 6, 2016 · 3 comments
Assignees
Labels
Android Mapbox Maps SDK for Android

Comments

@AlexeyIke
Copy link

Android
mapbox-android-sdk:4.2.0-beta.3

Steps to trigger behavior

  1. We have a own map style with 'traffic' layers - http://vt.map.vl.ru/styles/primorye.json
    ("source": "traffic",)
  2. To display road traffic i fill ("traffic") layers with data using setFilter for each "traffic" layer
    ex:
    for free ways (green lines)
    LineLayer lineLayer = (LineLayer) Render.getInstance().getMapboxMap().getLayer("free");
    Filter.SimpleStatement statement = new Filter.SimpleStatement( "!in", "id", responseTraffic.toArray()
    lineLayer.setFilter(statement);

for "difficult" ways
LineLayer lineLayer = (LineLayer) Render.getInstance().getMapboxMap().getLayer("difficult");
Filter.SimpleStatement statement = new Filter.SimpleStatement( "in", "id", responseTraffic.toArray()
lineLayer.setFilter(statement);

responseTraffic - List with lines id's to display / filter

When number of responseTraffic (segments) more than ~ 500 i've have fail with code :

10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] JNI ERROR (app bug): local reference table overflow (max=512)
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] local reference table dump:
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] Last 10 entries (of 512):
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 511: 0x12d414d0 java.lang.Integer
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 510: 0x70637508 java.lang.Integer
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 509: 0x70637358 java.lang.Integer
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 508: 0x12d414c0 java.lang.Integer
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 507: 0x12d414b0 java.lang.Integer
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 506: 0x12d414a0 java.lang.Integer
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 505: 0x12d41490 java.lang.Integer
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 504: 0x12d41480 java.lang.Integer
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 503: 0x12d41460 java.lang.Integer
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 502: 0x12d41440 java.lang.Integer
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] Summary:
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 2 of java.lang.Class (2 unique instances)
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 6 of java.lang.String (6 unique instances)
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 1 of java.lang.String[](4 elements)
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116] 503 of java.lang.Integer (503 unique instances)
10-06 13:09:04.619 7213-7213/ru.vl.map A/art: art/runtime/indirect_reference_table.cc:116]
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] Runtime aborting...
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] Aborting thread:
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] "main" prio=5 tid=1 Runnable
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] | group="" sCount=0 dsCount=0 obj=0x7594ff70 self=0x724ac95a00
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] | sysTid=7213 nice=0 cgrp=default sched=0/0 handle=0x724ea7ba98
..... a lo of log
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] native: #13 pc 000000000008cd78 /data/app/ru.vl.map-2/lib/arm64/libmapbox-gl.so (???)
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] native: #14 pc 00000000000b1b1c /data/app/ru.vl.map-2/lib/arm64/libmapbox-gl.so (???)
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] native: #15 pc 000000000008cfac /data/app/ru.vl.map-2/oat/arm64/base.odex (Java_com_mapbox_mapboxsdk_style_layers_Layer_nativeSetFilter___3Ljava_lang_Object_2+152)
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] at com.mapbox.mapboxsdk.style.layers.Layer.nativeSetFilter(Native method)
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] at com.mapbox.mapboxsdk.style.layers.LineLayer.setFilter(LineLayer.java:74)
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] at com.mapbox.mapboxsdk.style.layers.LineLayer.setFilter(LineLayer.java:64)
10-06 13:09:04.833 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] at ru.vl.map.render.traffic.TrafficRender.renderTraffic(TrafficRender.java:233)
....
10-06 13:09:04.849 7213-7213/ru.vl.map A/art: art/runtime/runtime.cc:403] | state=S schedstat=( 30389634 1761198 13 ) utm=2 stm=0 core=2 HZ=100
10-06 13:09:04.850 7213-7213/ru.vl.map A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 7213 (ru.vl.map)

Expected behavior

Should work for many than 512 items

Actual behavior

Fail on lineLayer.setFilter(statement);

FYI:
Works fine if less than 500 values passed to Filter.SimpleStatement
Display all loaded segments (lines) by filter by rule
"!in", "id", new Integer [] {} - about ~segments (lines)

part of json style for traffic layers:

{
"minzoom": 6,
"layout": {
"visibility": "visible",
"line-join": "round",
"line-cap": "round"
},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"in",
"id"
]
],
"type": "line",
"source": "traffic",
"id": "free case",
"paint": {
"line-width": {
"base": 1,
"stops": [
[
8,
2
],
[
12,
2
],
[
22,
12
]
]
},
"line-color": "#dfdfdf",
"line-offset": {
"base": 1,
"stops": [
[
8,
1
],
[
12,
1
],
[
22,
9
]
]
},
"line-opacity": 0.6
},
"source-layer": "traffic",
"interactive": true
},
{
"minzoom": 6,
"layout": {
"visibility": "visible",
"line-join": "round",
"line-cap": "round"
},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"in",
"id"
]
],
"type": "line",
"source": "traffic",
"id": "difficult case",
"paint": {
"line-width": {
"base": 1,
"stops": [
[
8,
2
],
[
12,
2
],
[
22,
12
]
]
},
"line-color": "#dfdfdf",
"line-offset": {
"base": 1,
"stops": [
[
8,
1
],
[
12,
1
],
[
22,
9
]
]
},
"line-opacity": 0.6
},
"source-layer": "traffic",
"interactive": true
},
{
"minzoom": 6,
"id": "free",
"paint": {
"line-offset": {
"base": 1,
"stops": [
[
8,
1
],
[
12,
1
],
[
22,
9
]
]
},
"line-width": {
"base": 1,
"stops": [
[
8,
1
],
[
12,
1
],
[
22,
9
]
]
},
"line-color": "#1fb306",
"line-opacity": 0.6
},
"interactive": true,
"ref": "free case"
},
{
"minzoom": 6,
"id": "difficult",
"paint": {
"line-offset": {
"base": 1,
"stops": [
[
8,
1
],
[
12,
1
],
[
22,
9
]
]
},
"line-width": {
"base": 1,
"stops": [
[
8,
1
],
[
12,
1
],
[
22,
9
]
]
},
"line-color": "#fc8403",
"line-opacity": 0.6
},
"interactive": true,
"ref": "difficult case"
},

@ivovandongen ivovandongen added the Android Mapbox Maps SDK for Android label Oct 6, 2016
@ivovandongen ivovandongen added this to the android-v4.2.0 milestone Oct 6, 2016
@ivovandongen
Copy link
Contributor

@AlexeyIke Thanks for the report, I've fixed the issue.

I also made the Statement implementation classes private as your example shows that they confuse the intended usage. Your snippet:

Filter.SimpleStatement statement = new Filter.SimpleStatement( "!in", "id", responseTraffic.toArray()
lineLayer.setFilter(statement);

Would become:

Filter.SimpleStatement statement = Filter.notIn("id", responseTraffic.toArray());
lineLayer.setFilter(statement);

Or a little more compact (with static imports):

lineLayer.setFilter(notIn("id", responseTraffic.toArray()));

More examples:

@ivovandongen ivovandongen self-assigned this Oct 7, 2016
@AlexeyIke
Copy link
Author

Thanks, can i get library somewhere to test this fix?

@ivovandongen
Copy link
Contributor

@AlexeyIke I just merged the PR. The fix should be in the next snapshot. See these instructions on how to get the snapshot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

2 participants