Closed ecaestecker closed 9 years ago
cc @lgatto
I can confirm that rols does appear to break Shiny. Even this fails:
library(rols)
shiny::runExample('01_hello')
This works though:
library(XML)
library(XMLSchema)
library(SSOAP)
library(Biobase)
shiny::runExample('01_hello')
cc @duncantl
I think I found out what is happening, but I can't explain it. rols
defines an S4 class Map
and shiny
has an identically named Reference class, and this, or something related to that, is at the origin of the error.
The Map
class is actually a by-product of the SSOAP
package, that creates the functions and data structures that handle the SOAP queries and responses automatically.
Renaming class seems to work, but before proceeding with refactoring, I would prefer to see if there was not a more elegant way to deal with this, as the same error would probably occur with other packages that depend on SSOAP
as rols
.
Any ideas?
Where is the Map function defined in the SSOAP package? or is it defined by processing a WSDL document? I don't see Map defined in SSOAP or XMLSchema. If it is defined in genSOAPClientInterface(), you have control over where the classes are defined.
Yes, it is indeed generated by genSOAPClientInterface()
. The definitions are then written to a file with SSOAP:::makeTopLevelFunctions
and writeLines
, and shipped with the rols
package where are defined.
Apparently the unexported rols
and shiny
Map
classes somehow conflict, but I don't understand why. The quickest fix would be to rename one class (which I am happy to do), but the apparent reason for this error is intriguing.
The problem seems larger than only rols to me. I get the exact same crash with another package that I am developing but am at a loss to figure out what goes wrong... Just to say that the fix might be needed in R or shiny rather than in rols or SSOAP
Could you provide more details or a link to the package?
Unfortunately I can't share the whole package at this moment, trying to make a minimal version of it that still triggers the bug.. Initial guess is that the problem arises when inheriting from AssayData class from Biobase...
Do you have a class Map
in your package?
nope
have to give up on that for now, a barebones version of that package does not trigger the bug..
cc @wch @hadley, any ideas how conflicts of unexported names might cause problems?
I wonder if it's related to https://github.com/hadley/devtools/issues/427 - it's another weird namespace-y issue with RJSONIO involved.
OTOH it may be a problem with S4 correctly identifying super classes. Does the error change if you load rols
and shiny
in the other order?
I know that they've fixed some S4-related bugs in R-devel. It's worth trying this on the latest development version of R to see if the problem magically goes away.
All my reports are with R-devel (svn 64910, 2014-02-01). I am happy to update and try again if the fixes are more recent.
Here is my understanding of the issue, apparently related to two classes being called Map
.
library("rols")
library("shiny")
shiny::runExample("01_hello")
## Listening on port 5235
## Error in lapply(.dependents$values(), function(ctx) { :
## attempt to apply non-function
## Error: attempt to apply non-function
This is not the expected Map
Reference class with method $values(), as defined in shiny
.
rols:::getOntologyNames()
## Error in checkAtAssignment("Map", ".xData", "environment") :
## ‘.xData’ is not a slot in class “Map”
Again, this as not the Map
S4 class as defined in rols
.
Update The S4
slot should actually be .Data
instead of .xData
. Not really sure where that comes from - maybe from one of shiny
's .env = 'environment'
field.
If I do the same thing as above but load shiny
first, I get this warning in addition to the last error:
> rols:::getOntologyNames()
Error in checkAtAssignment("Map", ".xData", "environment") :
‘.xData’ is not a slot in class “Map”
In addition: Warning message:
In rm(list = as.character(handle), pos = .wsconns) :
object '33858416' not found
Updating my Map
to xMap
seems to fix the issue with rols
. I am happy to do that if no better solution is suggested.
@lgatto how did you see that Map triggered the problem? Just guess? My package doesn't use any class names that are also used by shiny..
@lgatto I think the version of R that you are using has the S4 fixes, so that's likely not the issue.
@hredestig The checkAtAssignment
error and its traceback
were somehow obvious. For the first one, I had to look the offending code in the shiny
repo to realise that .dependents
was an instance of shiny
's Map
reference class. Finally, as a global rename to something else seems to fix the problem from the rols
perspective, I can only conclude that this is the case, but without explaining it.
@lgatto we've moved away from reference classes in Shiny. Do you mind trying this again with the development version of Shiny?
Using the latest shiny
from github:
> packageVersion("shiny")
[1] ‘0.10.1.9006’
I re-ran the chunks that resulted in errors, and all seems fine now.
> library("rols")
This is 'rols' version 1.7.1
> library("shiny")
> shiny::runExample("01_hello")
Listening on http://127.0.0.1:5678
> rols:::getOntologyNames()
An object of class "getOntologyNamesReturn"
Slot "getOntologyNamesReturn":
Object of class "Map" with 93 items:
Keys: LSM, TADS, ...
Values: Leukocyte Surface Markers, Tick Gross Anatomy, ...
Thank you very much!
Excellent!
Kudos to R6! :+1:
Hi,
We are currently in a testing phase for shiny, and for our purposes we would require to load the bioconductor rols package. After adding library(rols), the first refresh works fine and will load rols correctly it seems, however upon refreshing the page again after editing server.R with additional functionalities, we receive the error (described below) from line 23 in reactives.R.
Any help in resolving this bug would be highly appreciated! Evelyne
server.R:
ui.R:
JavaScript console error: