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:
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
Please publish a self-contained minimal example on the public internet. There is nothing we can extract from the minimized stacktrace
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?
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
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.13GitHub
GitHub - daniel-goldstein/cheerpj-scala-example
Contribute to daniel-goldstein/cheerpj-scala-example development by creating an account on GitHub.
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
Is it sufficient to upload a JAR with a main method or you need a public site using CheerpJ?
Please make a pre-integrated website, github pages work
It should be live here. Let me know if there's anything I should modify, thank you for your patience!
This issue should be fixed with this build: https://cjrtnc.leaningtech.com/3_20231218_322/cj3loader.js
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?
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
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:
there seem to be no problems initializing with <5 elements.
What about more than exactly 5
same error. I binary searched starting from an original 24 elements to find the 5 cutoff
Problem should be fixed in: https://cjrtnc.leaningtech.com/3_20231220_323/cj3loader.js