wakatime / jetbrains-wakatime

IntelliJ IDEA, PyCharm, RubyMine, PhpStorm, AppCode, AndroidStudio, Goland, Rider, & WebStorm plugin for quantifying your coding.
https://wakatime.com/intellij-idea
BSD 3-Clause "New" or "Revised" License
1.12k stars 162 forks source link

Not tracking time correctly in phpStorm (found java.lang.IndexOutOfBoundsException: Wrong offset in logs) #244

Closed funder7 closed 1 year ago

funder7 commented 1 year ago

Hi, as reported in the title, I've noticed that time is not tracked correctly: today I've coded 9 hrs and only 3h and 24 mins are logged. Not right at all.

Here's the exception that I've found in the log file - it repeats every 10 minutes or so:

java.lang.IndexOutOfBoundsException: Wrong offset: 20259. Should be in range: [0, 7977]
    at com.intellij.openapi.editor.impl.LineSet.findLineIndex(LineSet.java:166)
    at com.intellij.openapi.editor.impl.DocumentImpl.getLineNumber(DocumentImpl.java:1015)
    at com.wakatime.intellij.plugin.WakaTime.getLineStats(WakaTime.java:621)
    at com.wakatime.intellij.plugin.CustomSaveListener.beforeDocumentSaving(CustomSaveListener.java:34)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:655)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:621)
    at com.intellij.util.messages.impl.MessageBusImplKt.executeOrAddToQueue(MessageBusImpl.kt:466)
    at com.intellij.util.messages.impl.ToDirectChildrenMessagePublisher.publish$intellij_platform_core(CompositeMessageBus.kt:262)
    at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:421)
    at jdk.proxy2/jdk.proxy2.$Proxy25.beforeDocumentSaving(Unknown Source)
    at jdk.internal.reflect.GeneratedMethodAccessor890.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.multiCast(FileDocumentManagerImpl.java:172)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$new$0(FileDocumentManagerImpl.java:127)
    at jdk.proxy2/jdk.proxy2.$Proxy25.beforeDocumentSaving(Unknown Source)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$doSaveDocumentInWriteAction$4(FileDocumentManagerImpl.java:411)
    at com.intellij.pom.core.impl.PomModelImpl.guardPsiModificationsIn(PomModelImpl.java:326)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.doSaveDocumentInWriteAction(FileDocumentManagerImpl.java:410)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$doSaveDocument$2(FileDocumentManagerImpl.java:371)
    at com.intellij.openapi.application.WriteAction.lambda$run$1(WriteAction.java:86)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:968)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:994)
    at com.intellij.openapi.application.WriteAction.run(WriteAction.java:85)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.doSaveDocument(FileDocumentManagerImpl.java:371)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.saveDocuments(FileDocumentManagerImpl.java:291)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.saveAllDocuments(FileDocumentManagerImpl.java:266)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.saveAllDocuments(FileDocumentManagerImpl.java:259)
    at com.intellij.terminal.JBTerminalPanel.lambda$focusGained$2(JBTerminalPanel.java:347)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
    at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:838)
    at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:454)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:74)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:114)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:36)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:749)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:909)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:756)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$5(IdeEventQueue.java:437)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:436)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
    at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:615)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:434)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:838)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:480)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
alanhamlett commented 1 year ago

That log shouldn't be related to any missing heartbeats. It's only a warning when the plugin can't detect the current line number of the cursor and is logged then ignored.

When did you start/stop working for the day?

funder7 commented 1 year ago

Started around 19:20 and finished in the morning around 6:00

alanhamlett commented 1 year ago

Your dashboard looks like it shows the same, if you look across the two days. Which hours of the day are missing?

funder7 commented 1 year ago

I'm not sure that everything is working properly, I never closed the IDE and as far as I remember did no breaks, I don't understand why usage is so fragmented!

alanhamlett commented 1 year ago

Try uninstalling the Browser extension... then your durations should be more solid. Even though it looks fragmented on your dashboard it still reports the correct total time because it adds up all those durations.

Also, turn off debug mode if you don't want that IndexOutOfBoundsException printed in your idea.log file.