r[((0 + c) | 0)] is not a function when instantiating object

Hello, thank you all for developing CheerpJ, it is an impressive tool! I am playing around with trying to run hail, a scientific computing stack based on the JVM, in the browser using CheerpJ as I would love to eventually develop in-browser runnable documentation. I am able to load my JAR successfully, run some static methods on classes of mine and even instantiate some simple classes/case classes (this is a Scala project), but I'm running into the following error when trying to instantiate one of my core classes:
a.message: r[((0 + c) | 0)] is not a function
a.stacktrace: "TypeError: r[((0 + c) | 0)] is not a function\n at Object.u4 [as a0] (https://cjrtnc.leaningtech.com/3.0rc2/cj3.js:1:10866)\n at PG (https://cjrtnc.leaningtech.com/3.0rc2/cj3.js:1:67131)\n at MessagePort.Uo (https://cjrtnc.leaningtech.com/3.0rc2/cj3.js:1:20680)"
a.message: r[((0 + c) | 0)] is not a function
a.stacktrace: "TypeError: r[((0 + c) | 0)] is not a function\n at Object.u4 [as a0] (https://cjrtnc.leaningtech.com/3.0rc2/cj3.js:1:10866)\n at PG (https://cjrtnc.leaningtech.com/3.0rc2/cj3.js:1:67131)\n at MessagePort.Uo (https://cjrtnc.leaningtech.com/3.0rc2/cj3.js:1:20680)"
This class has a lot of dependencies, including some objects that do filesystem access that I would expect not to work in the browser, but this error is happening during object construction where it's just setting a couple String fields. The project is fully open source so I can provide a branch and steps to reproduce this error but I was hoping first to distill it into a more minimal example. Unfortately, I'm quite stuck as to what might be the problem here. Does this error mean anything to anyone / could I get some pointers as to how to further debug the error? Thank you in advance!
15 Replies
apignotti
apignotti12mo ago
Please publish a self-contained minimal example on the public internet. There is nothing we can extract from the minimized stacktrace
cyberland cow
cyberland cowOP12mo ago
Ok, I will try to produce a minimal example, but I am currently resorting to binary-search style deleting code from the codebase, so it might take a while. Is there a debug/verbose mode I can set in CheerpJ or anything to aid in the search?
apignotti
apignotti12mo ago
No, but we have internal assertion enabled build that help debugging these problem. It might be ok for the example to be not completely minimal, but the smaller it is the easier it is for us to quickly help
cyberland cow
cyberland cowOP12mo ago
Apologies for the delay, I believe I have significantly reduced the scope of this error. I believe I've gotten it down to a Scala-specific problem where CheerpJ fails to load something in the Scala Predef class definition. This is an implicit import in many Scala compilation units to give convenient shorthands for common container types along with many other QoL things. I've created a repo for reproduction with steps in the README. Interestingly, I only see this problem in Scala 2.12, not scala 2.13 (the README includes instructions for that too). Unfortunately I'm not yet able to discern if everything in Scala 2.13 is OK because it's a nontrivial lift to get my codebase to compile with 2.13
GitHub
GitHub - daniel-goldstein/cheerpj-scala-example
Contribute to daniel-goldstein/cheerpj-scala-example development by creating an account on GitHub.
apignotti
apignotti12mo ago
Please make a deployed version on publicly accessible URL. It is very time consuming for us to learn how to build every single test app We have no use for source anyway
cyberland cow
cyberland cowOP12mo ago
Is it sufficient to upload a JAR with a main method or you need a public site using CheerpJ?
apignotti
apignotti12mo ago
Please make a pre-integrated website, github pages work
cyberland cow
cyberland cowOP12mo ago
It should be live here. Let me know if there's anything I should modify, thank you for your patience!
apignotti
apignotti12mo ago
This issue should be fixed with this build: https://cjrtnc.leaningtech.com/3_20231218_322/cj3loader.js
cyberland cow
cyberland cowOP12mo ago
Thank you for the quick fix! I can confirm that the original problem seems to be resolved, but I hit another snag not much later. I've updated that same page with the new error. Would it be better to start a new thread or un-resolve this thread?
apignotti
apignotti12mo ago
I have un-resolved this one. It might take a while for us to get back to this problem. This code seems to do lots of non-standard use of the invokedynamic instruction
cyberland cow
cyberland cowOP12mo ago
Thank you! I appreciate any time you all are willing to spend on this, and it doesn't surprise me that there are some dragons in the Scala collection implementations... unfortunately that's what we're stuck with for the foreseeable future. For posterity, the problem code is:
val defaults = Map[String, String](
("a" -> "a"),
("b" -> "b"),
("c" -> "c"),
("d" -> "d"),
("e" -> "e"),
)
val defaults = Map[String, String](
("a" -> "a"),
("b" -> "b"),
("c" -> "c"),
("d" -> "d"),
("e" -> "e"),
)
there seem to be no problems initializing with <5 elements.
apignotti
apignotti12mo ago
What about more than exactly 5
cyberland cow
cyberland cowOP12mo ago
same error. I binary searched starting from an original 24 elements to find the 5 cutoff
Want results from more Discord servers?
Add your server