Problem with Basic UI/Android App not updating visibility elements

Posting here before creating an Issue. I’m currently running OH 2.5 SNAPSHOT 1634. I just reworked my charts in my sitemap to use images rather than embedded iFrames from Grafana. As part of this I’m going back to the old approach of having an Item to represent the desired time period and visibility tags to switch between images showing different time periods.

Here is my sitemap for this particular screenshot.

				// Temperature
				Switch item=ChartVisibility mappings=[Hour=Hour,Day=Day,Week=Week,Month=Month,Year=Year] 
				Image url="http://argus:8080/static/temph.jpg" refresh=5000 visibility=[ChartVisibility == "Hour", ChartVisibility == UNDEF]
				Image url="http://argus:8080/static/tempd.jpg" refresh=5000 visibility=[ChartVisibility == "Day"]
				Image url="http://argus:8080/static/tempw.jpg" refresh=5000 visibility=[ChartVisibility == "Week"]
				Image url="http://argus:8080/static/tempM.jpg" refresh=5000 visibility=[ChartVisibility == "Month"]
				Image url="http://argus:8080/static/tempy.jpg" refresh=5000 visibility=[ChartVisibility == "Year"]

Problem: The image doesn’t change when I click the button. But when I refresh the page it does show the new image. Also, if I wait long enough it will show the correct image.

ChartVisibility is changing state when I click on it.

I use visibility in other parts of my sitemap and they work just fine.

Is anyone else experiencing the same?

Are you by any chance running the beta version of the Android app? Could be related to this:

Yes I am, but I get the same behavior in both the app and in the browser. If that were the problem wouldn’t it work OK in the browser?

(emphasis in the quote by me)

This seems similar to what you are experiencing, however this was before @cweitkamp created issue #897 which was fixed in PR909.

Do you see a similar Null Pointer Exception in the logs?

I noticed in the Github issue that Christoph’s test sitemap only contains Text items, not Image items like you have in your sitemap. It could be that it is fixed for Text items, but not for other types.

No. I am seeing

org.glassfish.jersey.server.internal.process.MappableException: org.eclipse.jetty.io.EofException

but it doesn’t seem to be related to any activity I’m doing with the visibility elements. Here is the full stack trace in case it’s useful:

2019-07-08 13:19:40.795 [ERROR] [ersey.server.ServerRuntime$Responder] - An I/O error has occurred while writing a response message entity to the container output stream.
org.glassfish.jersey.server.internal.process.MappableException: org.eclipse.jetty.io.EofException
        at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:92) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[127:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130) ~[127:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:711) [128:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:444) [128:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:434) [128:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:329) [128:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [127:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [127:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [127:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [127:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [127:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [127:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [128:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [128:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) [125:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) [125:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) [125:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) [125:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) [125:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.openhab.core.thirdparty.com.eclipsesource.jaxrs.publisher.internal.ServletContainerBridge.service(ServletContainerBridge.java:75) [157:org.openhab.core.io.rest.publisher:2.5.0.2019
07050319]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:873) [91:org.eclipse.jetty.servlet:9.4.18.v20190429]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542) [91:org.eclipse.jetty.servlet:9.4.18.v20190429]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [196:org.ops4j.pax.web.pax-web-jetty:7.2.10]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [88:org.eclipse.jetty.security:9.4.18.v20190429]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1700) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) [196:org.ops4j.pax.web.pax-web-jetty:7.2.10]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480) [91:org.eclipse.jetty.servlet:9.4.18.v20190429]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1667) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [196:org.ops4j.pax.web.pax-web-jetty:7.2.10]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.Server.handle(Server.java:505) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267) [90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) [81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) [93:org.eclipse.jetty.util:9.4.18.v20190429]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) [93:org.eclipse.jetty.util:9.4.18.v20190429]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) [93:org.eclipse.jetty.util:9.4.18.v20190429]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) [93:org.eclipse.jetty.util:9.4.18.v20190429]
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) [93:org.eclipse.jetty.util:9.4.18.v20190429]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:698) [93:org.eclipse.jetty.util:9.4.18.v20190429]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:804) [93:org.eclipse.jetty.util:9.4.18.v20190429]
        at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: org.eclipse.jetty.io.EofException
        at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:284) ~[81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:393) ~[81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:277) ~[81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:380) ~[81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpConnection$SendCallback.process(HttpConnection.java:814) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241) ~[93:org.eclipse.jetty.util:9.4.18.v20190429]
        at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224) ~[93:org.eclipse.jetty.util:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:550) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:845) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:921) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:249) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:225) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:550) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at java.io.OutputStream.write(OutputStream.java:75) ~[?:?]
        at org.glassfish.jersey.servlet.internal.ResponseWriter$NonCloseableOutputStreamWrapper.write(ResponseWriter.java:320) ~[?:?]
        at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:218) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:294) ~[?:?]
        at org.eclipse.smarthome.io.rest.core.internal.GsonProvider.writeTo(GsonProvider.java:71) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[?:?]
        at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[?:?]
        at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86) ~[?:?]
        ... 53 more
Caused by: java.io.IOException: Connection reset by peer
        at sun.nio.ch.FileDispatcherImpl.writev0(Native Method) ~[?:?]
        at sun.nio.ch.SocketDispatcher.writev(SocketDispatcher.java:51) ~[?:?]
        at sun.nio.ch.IOUtil.write(IOUtil.java:148) ~[?:?]
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:504) ~[?:?]
        at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:264) ~[81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:393) ~[81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:277) ~[81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:380) ~[81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:380) ~[81:org.eclipse.jetty.io:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpConnection$SendCallback.process(HttpConnection.java:814) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241) ~[93:org.eclipse.jetty.util:9.4.18.v20190429]
        at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224) ~[93:org.eclipse.jetty.util:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:550) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:845) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:921) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:249) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:225) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:550) ~[90:org.eclipse.jetty.server:9.4.18.v20190429]
        at java.io.OutputStream.write(OutputStream.java:75) ~[?:?]
        at org.glassfish.jersey.servlet.internal.ResponseWriter$NonCloseableOutputStreamWrapper.write(ResponseWriter.java:320) ~[?:?]
        at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:218) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:294) ~[?:?]
        at org.eclipse.smarthome.io.rest.core.internal.GsonProvider.writeTo(GsonProvider.java:71) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[?:?]
        at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106) ~[?:?]
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[?:?]
        at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86) ~[?:?]
        ... 53 more

But I’ve been getting these for awhile, since before I made the changes with the Image elements posted above, and they seem to be related to one of my clients temporarily losing network access. When they appear I get the “waiting for connection to be restored” or something like that in BasicUI in the browser.

Also, I do have some visibility tagged elements that are working. It’s only these Image ones that don’t seem to update.

I edited my reply, not sure if you noticed the update.

The behavior you describe seems similar to that of @morph166955 (needing to refresh the page to reflect the change in visibility).

I noticed in the Github issue that Christoph’s test sitemap only contains Text items, not Image items like you have in your sitemap. It could be that it is fixed for Text items, but not for other types.

The other visibility tagged elements, are these images as well or just Text elements?

They are Switches actually:

		Switch item=aGarageOpener1 icon="garagedoorclosed" mappings=[ON=Open]  visibility=[vGarageOpener1 == CLOSED, vGarageOpener1 == UNDEF ]
		Switch item=aGarageOpener1 icon="garagedooropen"   mappings=[ON=Close] visibility=[vGarageOpener1 == OPEN]
		Switch item=aGarageOpener2 icon="garagedoorclosed" mappings=[ON=Open]  visibility=[vGarageOpener2 == CLOSED, vGarageOpener2 == UNDEF ]
		Switch item=aGarageOpener2 icon="garagedooropen"   mappings=[ON=Close] visibility=[vGarageOpener2 == OPEN]

...

		Switch item=ChristmasLights visibility=[vChristmas == ON]

There were recently 3 PRs impacting the visibility handling. Something has been broken apparently.

I noticed in the Github issue that Christoph’s test sitemap only contains Text items, not Image items like you have in your sitemap. It could be that it is fixed for Text items, but not for other types.

The issue in Christoph’s scenario was that there was one Sitemap widget that didn’t have a (valid) backing item, which is what triggered the NPE.

@rlkoshak Is snapshot 1634 older or newer than #691, IOW, is that fix included there? If it’s included there, I’d strongly suspect a caching issue; it’s very likely that both browser and Android app load the image from their cache. In the app, we bypass the cache for charts, but not for normal images.

2 Likes

Should be newer. If I read that issue correctly it was merged in May an this snapshot should be less than a week old.

I’ve a work around for now. Rather than using the visibility flag I just have the one Image element and rely on the refresh to show the right chart image. I’ll be posting that code over at Grafana Image Charts. But if there is a bug here I’d like to try diagnose it to help get it fixed.

From reading the thread of the issue it sure does sound like it could be related to the behavior I’m seeing. The Element doesn’t have an Item but it relies on the state of another Item for visibility.