Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Colin Alworth
    @niloc132
    yeah its a familiar pattern, other js certainly has that code too... i'm sure i've written it before too
    Jens Nehlmeier
    @jnehlmeier

    Is there any way to send an arraybuffer (provided through JS File API, wrapped into an Uint8Array) via GWT-RPC as byte array?

    I got a workaround for this

    @JeffQuesado_twitter Thanks, yes that would work although I am trying to avoid copying given that the file might be large.

    Colin Alworth
    @niloc132
    it will be copied anyway, to be put on the wire, so that might not be constructive?
    this is gwt 2.8.2 code, hence mixing and matching Any[]/JsArray<Any>, and exposes an api to JS, so i have to deal with arbitrary functions that they can pass in, and memoize large amounts of ticking data from the server
    Jens Nehlmeier
    @jnehlmeier
    yeah sure, but copying just to get an array that GWT knows about seems overkill. I mean Uint8Array is already what I want, it is just that GWT-RPC does not know it can be accessed and treated like a byte[]. But I think I decided against GWT-RPC and use plain XMLHttpRequest2 + FormData. That would also give access to progress events during upload.
    Colin Alworth
    @niloc132
    and let you send binary directly
    the other fix is what @rdeangelis83 suggested, make a wrapper object that has a byte[] field, and populate that manually
    (and serialize as string base64, since you can't write binary, you have to do utf-8)
    for "zero copy" you have to pass the entire buffer right to fetch/xhr
    Rocco De Angelis
    @rdeangelis83
    @niloc132 regarding your outputFunctionNameProperty patch. Can I help you somehow to bring this changes into the next GWT release?
    Jens Nehlmeier
    @jnehlmeier
    It must be FormData since the file has some additional information attached and I don't want to make two requests. Going low level is just a bit inconvenient that's why I thought to make it work with GWT-RPC. But I totally forgot upload progress. @niloc132 does your GWT-RPC implementation emit progress events?
    Colin Alworth
    @niloc132
    @jnehlmeier no, but trivial to add - the serialization is separate from the "remote service" endpoint generation, which is still separate from the actual "how do i send", so reimplementing your fetch or xhr wrapper is a dozen lines of code, and will be generic with any given endpoint
    Jens Nehlmeier
    @jnehlmeier
    @niloc132 sounds interesting, but I guess your implementation isn't battle tested and has some rough edges given it is more or less a personal project?
    Colin Alworth
    @niloc132
    i mean its only been in production for about 2-3 years
    Jens Nehlmeier
    @jnehlmeier
    I am just a bit cautious when it comes to libs with few people behind it.
    Colin Alworth
    @niloc132
    the deephaven-core project above uses grpc, but the "enterprise" version is all my gwt-rpc via websockets
    there are bugs, but not ones that have directly affect our use case, where sending lots of dense data over short intervals is important - there is a specific generics bug that might be a headache depending on what you're doing
    Jens Nehlmeier
    @jnehlmeier
    Well just command pattern with some generics.
    Colin Alworth
    @niloc132
    it still won't be "zero" copy
    interestingly, when we moved from gwt-rpc to grpc (with flatbuffer headers and arrow buf payloads, ostensibly zero copy) for reading data, we noticed about a 5% perf improvement for ~30k row tables, but then again instead of entirely auto-generated deserialization, i had to rewrite everything by hand
    i was expecting a way bigger improvement since doing it all by hand meant less copies, more direct code (less indirection etc)
    the dominating perf issue is still "longs suck", but large rapidly ticking charts get their updates promptly, so in the end it barely mattered
    (the lesson: measure, then cut)
    dac2k9
    @dac2k9_twitter
    3 replies
    Or Goshen
    @Oberonc
    How do you format a Date() into a String these days ?
    .. in GWT ~3 that is
    Thomas Broyer
    @tbroyer
    Either use Intl.DateTimeFormat through JsInterop, or have a look at https://github.com/treblereel/gwt-datetime (available on Vertispan's repository)
    Dmitrii Tikhomirov
    @treblereel
    right now in my work i need maybe all gwt3 modules, so i forked them https://github.com/treblereel/gwtproject and published to my private repo
    Jefferson Quesado
    @JeffQuesado_twitter
    Does GWT accepts Java instanceof pattern matching? It is not stated explicitly in the changelogs, but as it was launched in may-2020 and the JDK14 had this previes back in mar-2020, maybe it has some support?
    Colin Alworth
    @niloc132
    @JeffQuesado_twitter gwt 2.9 (and current HEAD) support java 11 syntax
    having a jdk preview doesn't help us, we need solid support in JDT (not just a preview, for example)
    norzak
    @norzak
    Is there a faster way to convert Int8ArrayNative to byte[]?
    norzak
    @norzak
    Same question for elemental2 Int8Array to byte[]
    Colin Alworth
    @niloc132
    @norzak c.g.g's Int8ArrayNative and elemental2's Int8Array are the same type in plain JS
    if you are just iterating the contents of the byte[], you can just do a Js.uncheckedCast to get from either to byte[] (but not vice versa)
    if however you are actually serializing this via gwt-rpc or doing anything else which will call array.getClass() and expect a byte[] type back, then you must instantiate the byte[] in java and copy the values over
    norzak
    @norzak
    @niloc132 thanks for the reply. not vice versa part is the one I wanted. Anyways, thanks for the info on gwt-rpc.
    Colin Alworth
    @niloc132
    @norzak can you clarify on what you're trying to do? if you're saying that you did want the "turn byte[] into typedarray" (i'm not quite sure what you were saying there), you might be able to find a way, such as creating a typed array, casting to byte[], populating it through something, and then consuming it that way
    but it will really depend on what exactly you had in mind
    (and as ever, measure, then cut, the naive implementation of what you're thinking on might already be pretty good)
    norzak
    @norzak
    @niloc132 sorry for the late reply. I think what I have is already the only way to implement using GWT on array conversions. On the other hand, I hit a very peculiar exception today. Knowing JavaScript is not a concurrent runtime, I am getting an interesting "Uncaught Error: java.util.ConcurrentModificationException" on my compiled javaScript application. How is that event possible? probably the iterator of the array list, very interesting.
    Colin Alworth
    @niloc132
    @norzak without threads, you can still hit a CME by modifying while iterating
    most commonly you have a for-each loop on a collection, and within that loop, modify the collection
    if you add an item to a list, does it skip that? does it go back and iterate it? etc
    java semantics, even within a single thread, are to throw that exception to indicate it was modified during iteration
    norzak
    @norzak
    @niloc132 just looked at the AbstractHashMap code, I am deleting while iterating. Interestingly bytecode version never complained about it because deleting while iterating in a single thread should be okay to my understanding.
    norzak
    @norzak
    @niloc132 I have fixed it. Still very interesting to see that the iteration is not very reliable.
    Colin Alworth
    @niloc132
    at least as of java8, java.util.HashMapHashIterator.nextNode() can hit this just if the modcount doesnt match, same as gwt