-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
include/mbgl/style/conversion.hpp
Outdated
|
||
// https://github.com/mapbox/mapbox-gl-native/issues/5623 | ||
optional<GeoJSON> (*toGeoJSON) (const Storage&, Error&); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you decide to implement this as an explicit data structure vs. relying on C++' built-in virtual call system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it doesn't require heap allocation and using unique_ptr
everywhere.
include/mbgl/style/conversion.hpp
Outdated
struct Error { std::string message; }; | ||
|
||
class Value { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not feeling great about introducing another class called Value
. Is there a different name that would fit too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSONValue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convertee
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going with Convertible
, as suggested by @1ec5.
Also, amazing size reductions! |
@jfirebaugh @kkaefer do you feel good about going ahead with this approach? I'd like to rebase the expressions branch onto it to see how that looks, but in order to do so I'll need to implement this new system for node (v8::Value) conversion. (While we're at it, we will also either need to solve |
Some additions in #10184:
TBD:
|
@jfirebaugh @kkaefer I went ahead and merged in the additions from #10184 (it's linear, so we can always revert, but seems easier to review in one place) The main remaining item other than getting & responding to a review is to set the size of the size of the Also @jfirebaugh re: @kkaefer 's point above about the name |
fe5fdcd
to
730ebd6
Compare
Rebased onto master to resolve a conflict; previous version of "Move conversions to cpp files where possible" is at cd7e4c2 |
800c095
to
18f9fc6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package-lock.json got added accidentally.
include/mbgl/style/conversion.hpp
Outdated
} | ||
|
||
template <typename T> | ||
void destroy (detail::Storage& storage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inverse of placement new is calling the destructor manually, so this can be written:
template <typename T>
void destroy (detail::Storage& storage) {
cast<T>(storage).~T();
}
Then inline it.
include/mbgl/style/conversion.hpp
Outdated
} | ||
|
||
template <typename T> | ||
void move(detail::Storage&& src, detail::Storage& dest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline this too.
include/mbgl/style/conversion.hpp
Outdated
*/ | ||
|
||
namespace detail { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can Storage
nest in Value
instead?
include/mbgl/style/conversion.hpp
Outdated
struct Error { std::string message; }; | ||
|
||
template <typename T> | ||
const T& cast(const detail::Storage& storage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If reinterpret_cast
s work, just use them inline.
const v8::Local<v8::Value> value(std::move(cast(storage))); | ||
(void)value; // appease linter | ||
} | ||
using V8Value = v8::Local<v8::Value>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this typedef adds much value. I'd rather just use v8::Local<v8::Value>
directly.
new (static_cast<void*>(&dest)) JSValue* (std::move(*static_cast<JSValue**>(static_cast<void*>(&src)))); | ||
destroy(src); | ||
} | ||
using JSValuePointer = const JSValue*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
b9fdcce
to
d0a0b39
Compare
@jfirebaugh updated to address review comments and get CI passing (I'll have to look at the one failing android build tomorrow). Questions: |
2350824
to
d42caff
Compare
CI is crashing on Android:
@anandthakker Do you remember seeing this before or is it something I introduced with the latest changes? |
Y, I saw this before, hadn’t yet dug in to it
…On Tue, Oct 17, 2017 at 9:27 PM John Firebaugh ***@***.***> wrote:
CI is crashing on Android:
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Stack frame #00 pc 0003b0ec /system/lib/libc.so (tgkill+12)
Stack frame #1 pc 000173c1 /system/lib/libc.so (pthread_kill+52)
Stack frame #2 pc 00017fd3 /system/lib/libc.so (raise+10)
Stack frame #3 pc 00014795 /system/lib/libc.so (__libc_android_abort+36)
Stack frame #4 pc 00012f44 /system/lib/libc.so (abort+4)
Stack frame #5 pc 00228cd7 /system/lib/libart.so (art::Runtime::Abort()+170)
Stack frame #6 pc 000a7371 /system/lib/libart.so (art::LogMessage::~LogMessage()+1360)
Stack frame #7 pc 000b1b17 /system/lib/libart.so (art::JniAbort(char const*, char const*)+1118)
Stack frame #8 pc 000b2055 /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+68)
Stack frame #9 pc 000b453b /system/lib/libart.so (_ZN3art11ScopedCheck5CheckEbPKcz.constprop.129+710)
Stack frame #10 pc 000b76eb /system/lib/libart.so (art::CheckJNI::IsInstanceOf(_JNIEnv*, _jobject*, _jclass*)+50)
Stack frame #11 pc 00109d4d /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #12 pc 00109ca1 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #13 pc 00128e1b /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #14 pc 0008e93d /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #15 pc 0008e919 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #16 pc 0008e8f5 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #17 pc 0008d2b5 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #18 pc 00317a57 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #19 pc 003178ad /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #20 pc 003176b1 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #21 pc 003174fd /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #22 pc 00317455 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #23 pc 00365c0b /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #24 pc 002f8953 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #25 pc 0014ecbb /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #26 pc 00151bb3 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #27 pc 00151b11 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #28 pc 00151aab /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #29 pc 00151c7d /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #30 pc 00151c13 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
Stack frame #31 pc 0019b1bf ***@***.***@***@***.***@classes.dex
@anandthakker <https://github.com/anandthakker> Do you remember seeing
this before or is it something I introduced with the latest changes?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10075 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEvmR_cxheuz4RPBkjojWuYyiPaPbErDks5stVQWgaJpZM4Pk_YB>
.
|
fe786a1
to
5193d5b
Compare
I'm able to reproduce the crash locally. I believe it's due to |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
@jfirebaugh LGTM, with the caveat that I don't fully understand why the switch from const refs to moves solves the android problem
include/mbgl/style/conversion.hpp
Outdated
// Qt: JSValue* or QVariant | ||
|
||
// TODO: use platform-specific size | ||
using Storage = std::aligned_storage_t<32, 8>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that when I changed this from 16 to 32, I didn't actually confirm that 32 was the minimum sufficient size, because I thought we'd be able to just use sizeof(platform_specific_type)
when we did the platform-specific sizing.
Value(jni::JNIEnv&, jni::jobject*); | ||
virtual ~Value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the virtual destructor here in the first place? Was Value used as a base class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there was any reason for it.
1e53e9a
to
4e6c498
Compare
Hi, |
Value
std::aligned_storage
based on environment: we know which type is used for each platform, so we can usemax(sizeof(JSValue*), sizeof(PLATFORM_VALUE_TYPE))
make_property_setters.hpp.ejs
needs to be updatedFirst pass at a bit of binary size reduction by reducing templating in the
mbgl::style::conversions
namespace.On macOS framework:
cc @kkaefer @anandthakker